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)
|
||||
- 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 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
|
||||
|
||||
### v2.0.0 (2021-11-15)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
// Redux
|
||||
import { useSelector } from 'react-redux';
|
||||
import { State } from '../../../store/reducers';
|
||||
|
||||
// CSS
|
||||
import classes from './Header.module.css';
|
||||
|
||||
|
@ -12,6 +16,10 @@ import { getDateTime } from './functions/getDateTime';
|
|||
import { greeter } from './functions/greeter';
|
||||
|
||||
export const Header = (): JSX.Element => {
|
||||
const { hideHeader, hideDate, showTime } = useSelector(
|
||||
(state: State) => state.config.config
|
||||
);
|
||||
|
||||
const [dateTime, setDateTime] = useState<string>(getDateTime());
|
||||
const [greeting, setGreeting] = useState<string>(greeter());
|
||||
|
||||
|
@ -28,14 +36,18 @@ export const Header = (): JSX.Element => {
|
|||
|
||||
return (
|
||||
<header className={classes.Header}>
|
||||
<p>{dateTime}</p>
|
||||
{(!hideDate || showTime) && <p>{dateTime}</p>}
|
||||
|
||||
<Link to="/settings" className={classes.SettingsLink}>
|
||||
Go to Settings
|
||||
</Link>
|
||||
<span className={classes.HeaderMain}>
|
||||
<h1>{greeting}</h1>
|
||||
<WeatherWidget />
|
||||
</span>
|
||||
|
||||
{!hideHeader && (
|
||||
<span className={classes.HeaderMain}>
|
||||
<h1>{greeting}</h1>
|
||||
<WeatherWidget />
|
||||
</span>
|
||||
)}
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -30,22 +30,42 @@ export const getDateTime = (): string => {
|
|||
|
||||
const useAmericanDate = localStorage.useAmericanDate === '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(
|
||||
now.getSeconds()
|
||||
)}`;
|
||||
|
||||
const timeEl = showTime ? ` - ${time}` : '';
|
||||
|
||||
if (!useAmericanDate) {
|
||||
return `${days[now.getDay()]}, ${now.getDate()} ${
|
||||
months[now.getMonth()]
|
||||
} ${now.getFullYear()}${timeEl}`;
|
||||
} else {
|
||||
return `${days[now.getDay()]}, ${
|
||||
months[now.getMonth()]
|
||||
} ${now.getDate()} ${now.getFullYear()}${timeEl}`;
|
||||
if (!hideDate) {
|
||||
if (!useAmericanDate) {
|
||||
dateEl = `${days[now.getDay()]}, ${now.getDate()} ${
|
||||
months[now.getMonth()]
|
||||
} ${now.getFullYear()}`;
|
||||
} else {
|
||||
dateEl = `${days[now.getDay()]}, ${
|
||||
months[now.getMonth()]
|
||||
} ${now.getDate()} ${now.getFullYear()}`;
|
||||
}
|
||||
}
|
||||
|
||||
// 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>
|
||||
)}
|
||||
|
||||
{!config.hideHeader ? <Header /> : <div></div>}
|
||||
<Header />
|
||||
|
||||
{!config.hideApps ? (
|
||||
<Fragment>
|
||||
|
|
|
@ -66,7 +66,7 @@ export const UISettings = (): JSX.Element => {
|
|||
|
||||
return (
|
||||
<form onSubmit={(e) => formSubmitHandler(e)}>
|
||||
{/* OTHER OPTIONS */}
|
||||
{/* === OTHER OPTIONS === */}
|
||||
<SettingsHeadline text="Miscellaneous" />
|
||||
{/* PAGE TITLE */}
|
||||
<InputGroup>
|
||||
|
@ -81,6 +81,50 @@ export const UISettings = (): JSX.Element => {
|
|||
/>
|
||||
</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 */}
|
||||
<InputGroup>
|
||||
<label htmlFor="useAmericanDate">Date formatting</label>
|
||||
|
@ -95,7 +139,52 @@ export const UISettings = (): JSX.Element => {
|
|||
</select>
|
||||
</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" />
|
||||
{/* PIN APPS */}
|
||||
<InputGroup>
|
||||
|
@ -172,82 +261,7 @@ export const UISettings = (): JSX.Element => {
|
|||
</select>
|
||||
</InputGroup>
|
||||
|
||||
{/* HEADER 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 */}
|
||||
{/* === MODULES OPTIONS === */}
|
||||
<SettingsHeadline text="Modules" />
|
||||
{/* HIDE APPS */}
|
||||
<InputGroup>
|
||||
|
|
|
@ -30,4 +30,5 @@ export interface Config {
|
|||
defaultTheme: string;
|
||||
isKilometer: boolean;
|
||||
weatherData: WeatherData;
|
||||
hideDate: boolean;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ export interface OtherSettingsForm {
|
|||
daySchema: string;
|
||||
monthSchema: string;
|
||||
showTime: boolean;
|
||||
hideDate: boolean;
|
||||
}
|
||||
|
||||
export interface DockerSettingsForm {
|
||||
|
|
|
@ -19,6 +19,7 @@ const keys: (keyof Config)[] = [
|
|||
'daySchema',
|
||||
'monthSchema',
|
||||
'showTime',
|
||||
'hideDate',
|
||||
];
|
||||
|
||||
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
||||
|
|
|
@ -31,4 +31,5 @@ export const configTemplate: Config = {
|
|||
defaultTheme: 'tron',
|
||||
isKilometer: true,
|
||||
weatherData: 'cloud',
|
||||
hideDate: false,
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@ export const otherSettingsTemplate: OtherSettingsForm = {
|
|||
monthSchema:
|
||||
'January;February;March;April;May;June;July;August;September;October;November;December',
|
||||
showTime: false,
|
||||
hideDate: false,
|
||||
};
|
||||
|
||||
export const weatherSettingsTemplate: WeatherForm = {
|
||||
|
|
|
@ -27,5 +27,6 @@
|
|||
"showTime": false,
|
||||
"defaultTheme": "tron",
|
||||
"isKilometer": true,
|
||||
"weatherData": "cloud"
|
||||
"weatherData": "cloud",
|
||||
"hideDate": false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue