mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
Added settings button.
This commit is contained in:
parent
4f098a34c1
commit
c3a4d6c725
@ -13,6 +13,7 @@ import useConfig from 'hooks/useConfig';
|
||||
import useUser from 'hooks/useUser';
|
||||
import Logo from 'assets/logo.svg';
|
||||
import styles from './Header.module.css';
|
||||
import SettingsButton from '../settings/SettingsButton';
|
||||
|
||||
export default function Header() {
|
||||
const { user } = useUser();
|
||||
@ -46,6 +47,7 @@ export default function Header() {
|
||||
<div className={styles.buttons}>
|
||||
<ThemeButton />
|
||||
<LanguageButton menuAlign="right" />
|
||||
<SettingsButton />
|
||||
{user && !adminDisabled && <UserButton />}
|
||||
</div>
|
||||
</header>
|
||||
|
45
components/settings/SettingsButton.js
Normal file
45
components/settings/SettingsButton.js
Normal file
@ -0,0 +1,45 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import TimezoneSetting from './TimezoneSetting';
|
||||
import DateRangeSetting from './DateRangeSetting';
|
||||
import Button from 'components/common/Button';
|
||||
import styles from './SettingsButton.module.css';
|
||||
import Gear from 'assets/gear.svg';
|
||||
import useDocumentClick from '../../hooks/useDocumentClick';
|
||||
|
||||
export default function SettingsButton() {
|
||||
const [show, setShow] = useState(false);
|
||||
const ref = useRef();
|
||||
|
||||
function handleClick() {
|
||||
setShow(state => !state);
|
||||
}
|
||||
|
||||
useDocumentClick(e => {
|
||||
if (!ref.current?.contains(e.target)) {
|
||||
setShow(false);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={styles.button} ref={ref}>
|
||||
<Button icon={<Gear />} variant="light" onClick={handleClick} />
|
||||
{show && (
|
||||
<div className={styles.panel}>
|
||||
<dt>
|
||||
<FormattedMessage id="label.timezone" defaultMessage="Timezone" />
|
||||
</dt>
|
||||
<dd>
|
||||
<TimezoneSetting />
|
||||
</dd>
|
||||
<dt>
|
||||
<FormattedMessage id="label.default-date-range" defaultMessage="Default date range" />
|
||||
</dt>
|
||||
<dd>
|
||||
<DateRangeSetting />
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
20
components/settings/SettingsButton.module.css
Normal file
20
components/settings/SettingsButton.module.css
Normal file
@ -0,0 +1,20 @@
|
||||
.button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--gray50);
|
||||
border: 1px solid var(--gray500);
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
padding: 20px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.panel dd {
|
||||
display: flex;
|
||||
}
|
Loading…
Reference in New Issue
Block a user