Added option to hide header greetings and date separately
This commit is contained in:
parent
5cf7708ab8
commit
85a65aef52
11 changed files with 153 additions and 100 deletions
|
@ -1,6 +1,7 @@
|
||||||
### v2.0.1 (TBA)
|
### v2.0.1 (TBA)
|
||||||
- Added option to display humidity in the weather widget ([#136](https://github.com/pawelmalak/flame/issues/136))
|
- Added option to display humidity in the weather widget ([#136](https://github.com/pawelmalak/flame/issues/136))
|
||||||
- Added option to set default theme for all new users ([#165](https://github.com/pawelmalak/flame/issues/165))
|
- Added option to set default theme for all new users ([#165](https://github.com/pawelmalak/flame/issues/165))
|
||||||
|
- Added option to hide header greetings and date separately ([#200](https://github.com/pawelmalak/flame/issues/200))
|
||||||
- Fixed bug with custom icons not working with apps when "pin by default" was disabled
|
- Fixed bug with custom icons not working with apps when "pin by default" was disabled
|
||||||
|
|
||||||
### v2.0.0 (2021-11-15)
|
### v2.0.0 (2021-11-15)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
// Redux
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { State } from '../../../store/reducers';
|
||||||
|
|
||||||
// CSS
|
// CSS
|
||||||
import classes from './Header.module.css';
|
import classes from './Header.module.css';
|
||||||
|
|
||||||
|
@ -12,6 +16,10 @@ import { getDateTime } from './functions/getDateTime';
|
||||||
import { greeter } from './functions/greeter';
|
import { greeter } from './functions/greeter';
|
||||||
|
|
||||||
export const Header = (): JSX.Element => {
|
export const Header = (): JSX.Element => {
|
||||||
|
const { hideHeader, hideDate, showTime } = useSelector(
|
||||||
|
(state: State) => state.config.config
|
||||||
|
);
|
||||||
|
|
||||||
const [dateTime, setDateTime] = useState<string>(getDateTime());
|
const [dateTime, setDateTime] = useState<string>(getDateTime());
|
||||||
const [greeting, setGreeting] = useState<string>(greeter());
|
const [greeting, setGreeting] = useState<string>(greeter());
|
||||||
|
|
||||||
|
@ -28,14 +36,18 @@ export const Header = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={classes.Header}>
|
<header className={classes.Header}>
|
||||||
<p>{dateTime}</p>
|
{(!hideDate || showTime) && <p>{dateTime}</p>}
|
||||||
|
|
||||||
<Link to="/settings" className={classes.SettingsLink}>
|
<Link to="/settings" className={classes.SettingsLink}>
|
||||||
Go to Settings
|
Go to Settings
|
||||||
</Link>
|
</Link>
|
||||||
<span className={classes.HeaderMain}>
|
|
||||||
<h1>{greeting}</h1>
|
{!hideHeader && (
|
||||||
<WeatherWidget />
|
<span className={classes.HeaderMain}>
|
||||||
</span>
|
<h1>{greeting}</h1>
|
||||||
|
<WeatherWidget />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,22 +30,42 @@ export const getDateTime = (): string => {
|
||||||
|
|
||||||
const useAmericanDate = localStorage.useAmericanDate === 'true';
|
const useAmericanDate = localStorage.useAmericanDate === 'true';
|
||||||
const showTime = localStorage.showTime === 'true';
|
const showTime = localStorage.showTime === 'true';
|
||||||
|
const hideDate = localStorage.hideDate === 'true';
|
||||||
|
|
||||||
const p = parseTime;
|
// Date
|
||||||
|
let dateEl = '';
|
||||||
|
|
||||||
const time = `${p(now.getHours())}:${p(now.getMinutes())}:${p(
|
if (!hideDate) {
|
||||||
now.getSeconds()
|
if (!useAmericanDate) {
|
||||||
)}`;
|
dateEl = `${days[now.getDay()]}, ${now.getDate()} ${
|
||||||
|
months[now.getMonth()]
|
||||||
const timeEl = showTime ? ` - ${time}` : '';
|
} ${now.getFullYear()}`;
|
||||||
|
} else {
|
||||||
if (!useAmericanDate) {
|
dateEl = `${days[now.getDay()]}, ${
|
||||||
return `${days[now.getDay()]}, ${now.getDate()} ${
|
months[now.getMonth()]
|
||||||
months[now.getMonth()]
|
} ${now.getDate()} ${now.getFullYear()}`;
|
||||||
} ${now.getFullYear()}${timeEl}`;
|
}
|
||||||
} else {
|
|
||||||
return `${days[now.getDay()]}, ${
|
|
||||||
months[now.getMonth()]
|
|
||||||
} ${now.getDate()} ${now.getFullYear()}${timeEl}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time
|
||||||
|
const p = parseTime;
|
||||||
|
let timeEl = '';
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
const time = `${p(now.getHours())}:${p(now.getMinutes())}:${p(
|
||||||
|
now.getSeconds()
|
||||||
|
)}`;
|
||||||
|
|
||||||
|
timeEl = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separator
|
||||||
|
let separator = '';
|
||||||
|
|
||||||
|
if (!hideDate && showTime) {
|
||||||
|
separator = ' - ';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output
|
||||||
|
return `${dateEl}${separator}${timeEl}`;
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,7 @@ export const Home = (): JSX.Element => {
|
||||||
<div></div>
|
<div></div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!config.hideHeader ? <Header /> : <div></div>}
|
<Header />
|
||||||
|
|
||||||
{!config.hideApps ? (
|
{!config.hideApps ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|
|
@ -66,7 +66,7 @@ export const UISettings = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => formSubmitHandler(e)}>
|
<form onSubmit={(e) => formSubmitHandler(e)}>
|
||||||
{/* OTHER OPTIONS */}
|
{/* === OTHER OPTIONS === */}
|
||||||
<SettingsHeadline text="Miscellaneous" />
|
<SettingsHeadline text="Miscellaneous" />
|
||||||
{/* PAGE TITLE */}
|
{/* PAGE TITLE */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -81,6 +81,50 @@ export const UISettings = (): JSX.Element => {
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* === HEADER OPTIONS === */}
|
||||||
|
<SettingsHeadline text="Header" />
|
||||||
|
{/* HIDE HEADER */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="hideHeader">Hide greetings</label>
|
||||||
|
<select
|
||||||
|
id="hideHeader"
|
||||||
|
name="hideHeader"
|
||||||
|
value={formData.hideHeader ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* HIDE DATE */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="hideDate">Hide date</label>
|
||||||
|
<select
|
||||||
|
id="hideDate"
|
||||||
|
name="hideDate"
|
||||||
|
value={formData.hideDate ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* HIDE TIME */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="showTime">Hide time</label>
|
||||||
|
<select
|
||||||
|
id="showTime"
|
||||||
|
name="showTime"
|
||||||
|
value={formData.showTime ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={0}>True</option>
|
||||||
|
<option value={1}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
{/* DATE FORMAT */}
|
{/* DATE FORMAT */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="useAmericanDate">Date formatting</label>
|
<label htmlFor="useAmericanDate">Date formatting</label>
|
||||||
|
@ -95,7 +139,52 @@ export const UISettings = (): JSX.Element => {
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* BEAHVIOR OPTIONS */}
|
{/* CUSTOM GREETINGS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="greetingsSchema">Custom greetings</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="greetingsSchema"
|
||||||
|
name="greetingsSchema"
|
||||||
|
placeholder="Good day;Hi;Bye!"
|
||||||
|
value={formData.greetingsSchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
Greetings must be separated with semicolon. Only 4 messages can be
|
||||||
|
used
|
||||||
|
</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* CUSTOM DAYS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="daySchema">Custom weekday names</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="daySchema"
|
||||||
|
name="daySchema"
|
||||||
|
placeholder="Sunday;Monday;Tuesday"
|
||||||
|
value={formData.daySchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>Names must be separated with semicolon</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* CUSTOM MONTHS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="monthSchema">Custom month names</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="monthSchema"
|
||||||
|
name="monthSchema"
|
||||||
|
placeholder="January;February;March"
|
||||||
|
value={formData.monthSchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>Names must be separated with semicolon</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* === BEAHVIOR OPTIONS === */}
|
||||||
<SettingsHeadline text="App Behavior" />
|
<SettingsHeadline text="App Behavior" />
|
||||||
{/* PIN APPS */}
|
{/* PIN APPS */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -172,82 +261,7 @@ export const UISettings = (): JSX.Element => {
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* HEADER OPTIONS */}
|
{/* === MODULES OPTIONS === */}
|
||||||
<SettingsHeadline text="Header" />
|
|
||||||
{/* HIDE HEADER */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="hideHeader">Hide greeting and date</label>
|
|
||||||
<select
|
|
||||||
id="hideHeader"
|
|
||||||
name="hideHeader"
|
|
||||||
value={formData.hideHeader ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM GREETINGS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="greetingsSchema">Custom greetings</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="greetingsSchema"
|
|
||||||
name="greetingsSchema"
|
|
||||||
placeholder="Good day;Hi;Bye!"
|
|
||||||
value={formData.greetingsSchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>
|
|
||||||
Greetings must be separated with semicolon. Only 4 messages can be
|
|
||||||
used
|
|
||||||
</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM DAYS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="daySchema">Custom weekday names</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="daySchema"
|
|
||||||
name="daySchema"
|
|
||||||
placeholder="Sunday;Monday;Tuesday"
|
|
||||||
value={formData.daySchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>Names must be separated with semicolon</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM MONTHS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="monthSchema">Custom month names</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="monthSchema"
|
|
||||||
name="monthSchema"
|
|
||||||
placeholder="January;February;March"
|
|
||||||
value={formData.monthSchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>Names must be separated with semicolon</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* SHOW TIME */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="showTime">Show time</label>
|
|
||||||
<select
|
|
||||||
id="showTime"
|
|
||||||
name="showTime"
|
|
||||||
value={formData.showTime ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* MODULES OPTIONS */}
|
|
||||||
<SettingsHeadline text="Modules" />
|
<SettingsHeadline text="Modules" />
|
||||||
{/* HIDE APPS */}
|
{/* HIDE APPS */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
|
|
@ -30,4 +30,5 @@ export interface Config {
|
||||||
defaultTheme: string;
|
defaultTheme: string;
|
||||||
isKilometer: boolean;
|
isKilometer: boolean;
|
||||||
weatherData: WeatherData;
|
weatherData: WeatherData;
|
||||||
|
hideDate: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ export interface OtherSettingsForm {
|
||||||
daySchema: string;
|
daySchema: string;
|
||||||
monthSchema: string;
|
monthSchema: string;
|
||||||
showTime: boolean;
|
showTime: boolean;
|
||||||
|
hideDate: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DockerSettingsForm {
|
export interface DockerSettingsForm {
|
||||||
|
|
|
@ -19,6 +19,7 @@ const keys: (keyof Config)[] = [
|
||||||
'daySchema',
|
'daySchema',
|
||||||
'monthSchema',
|
'monthSchema',
|
||||||
'showTime',
|
'showTime',
|
||||||
|
'hideDate',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
||||||
|
|
|
@ -31,4 +31,5 @@ export const configTemplate: Config = {
|
||||||
defaultTheme: 'tron',
|
defaultTheme: 'tron',
|
||||||
isKilometer: true,
|
isKilometer: true,
|
||||||
weatherData: 'cloud',
|
weatherData: 'cloud',
|
||||||
|
hideDate: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const otherSettingsTemplate: OtherSettingsForm = {
|
||||||
monthSchema:
|
monthSchema:
|
||||||
'January;February;March;April;May;June;July;August;September;October;November;December',
|
'January;February;March;April;May;June;July;August;September;October;November;December',
|
||||||
showTime: false,
|
showTime: false,
|
||||||
|
hideDate: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const weatherSettingsTemplate: WeatherForm = {
|
export const weatherSettingsTemplate: WeatherForm = {
|
||||||
|
|
|
@ -27,5 +27,6 @@
|
||||||
"showTime": false,
|
"showTime": false,
|
||||||
"defaultTheme": "tron",
|
"defaultTheme": "tron",
|
||||||
"isKilometer": true,
|
"isKilometer": true,
|
||||||
"weatherData": "cloud"
|
"weatherData": "cloud",
|
||||||
|
"hideDate": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue