mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-04 11:05:08 +01:00
Dark mode.
This commit is contained in:
parent
4bb95cd997
commit
aa265d1d42
@ -3,6 +3,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: var(--font-size-normal);
|
font-size: var(--font-size-normal);
|
||||||
|
color: var(--gray900);
|
||||||
background: var(--gray100);
|
background: var(--gray100);
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@ -18,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button:active {
|
.button:active {
|
||||||
color: initial;
|
color: var(--gray700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.large {
|
.large {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
.group .button {
|
.group .button {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
color: var(--gray800);
|
||||||
background: var(--gray50);
|
background: var(--gray50);
|
||||||
border-left: 1px solid var(--gray500);
|
border-left: 1px solid var(--gray500);
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
@ -24,6 +25,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.group .button.selected {
|
||||||
|
color: var(--gray900);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
padding-left: 10px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ a.link,
|
|||||||
a.link:active,
|
a.link:active,
|
||||||
a.link:visited {
|
a.link:visited {
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #2c2c2c;
|
color: var(--gray900);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ a.link:before {
|
|||||||
bottom: -2px;
|
bottom: -2px;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 2px;
|
height: 2px;
|
||||||
background: #2680eb;
|
background: var(--primary400);
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
transition: width 100ms;
|
transition: width 100ms;
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
.option {
|
.option {
|
||||||
font-size: var(--font-size-small);
|
font-size: var(--font-size-small);
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
background: #fff;
|
background: var(--gray50);
|
||||||
padding: 4px 16px;
|
padding: 4px 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option:hover {
|
.option:hover {
|
||||||
background: #f5f5f5;
|
background: var(--gray100);
|
||||||
}
|
}
|
||||||
|
|
||||||
.float {
|
.float {
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: var(--gray900);
|
background: #000;
|
||||||
opacity: 0.1;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
.menu {
|
.menu {
|
||||||
|
color: var(--gray800);
|
||||||
border: 1px solid var(--gray500);
|
border: 1px solid var(--gray500);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -16,5 +17,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
|
color: var(--gray900);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
color: var(--gray50);
|
color: var(--msgColor);
|
||||||
background: var(--green400);
|
background: var(--green400);
|
||||||
margin: auto;
|
margin: auto;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
@ -1,44 +1,57 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useMemo } from 'react';
|
||||||
import ReactTooltip from 'react-tooltip';
|
import ReactTooltip from 'react-tooltip';
|
||||||
|
import { ComposableMap, Geographies, Geography, ZoomableGroup } from 'react-simple-maps';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import { ComposableMap, Geographies, Geography, ZoomableGroup } from 'react-simple-maps';
|
import useTheme from 'hooks/useTheme';
|
||||||
|
import { THEME_COLORS } from 'lib/constants';
|
||||||
import styles from './WorldMap.module.css';
|
import styles from './WorldMap.module.css';
|
||||||
|
|
||||||
const geoUrl = '/world-110m.json';
|
const geoUrl = '/world-110m.json';
|
||||||
|
|
||||||
export default function WorldMap({
|
export default function WorldMap({ data, className }) {
|
||||||
data,
|
|
||||||
className,
|
|
||||||
baseColor = '#e9f3fd',
|
|
||||||
fillColor = '#f5f5f5',
|
|
||||||
strokeColor = '#2680eb',
|
|
||||||
hoverColor = '#2680eb',
|
|
||||||
}) {
|
|
||||||
const [tooltip, setTooltip] = useState();
|
const [tooltip, setTooltip] = useState();
|
||||||
|
const [theme] = useTheme();
|
||||||
|
const colors = useMemo(
|
||||||
|
() => ({
|
||||||
|
baseColor: THEME_COLORS[theme].primary,
|
||||||
|
fillColor: THEME_COLORS[theme].gray100,
|
||||||
|
strokeColor: THEME_COLORS[theme].primary,
|
||||||
|
hoverColor: THEME_COLORS[theme].primary,
|
||||||
|
}),
|
||||||
|
[theme],
|
||||||
|
);
|
||||||
|
|
||||||
function getFillColor(code) {
|
function getFillColor(code) {
|
||||||
if (code === 'AQ') return '#ffffff';
|
if (code === 'AQ') return;
|
||||||
const country = data?.find(({ x }) => x === code);
|
const country = data?.find(({ x }) => x === code);
|
||||||
return country ? tinycolor(baseColor).darken(country.z) : fillColor;
|
|
||||||
|
if (!country) {
|
||||||
|
return colors.fillColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tinycolor(colors.baseColor)[theme === 'light' ? 'lighten' : 'darken'](
|
||||||
|
40 * (1.0 - country.z / 100),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStrokeColor(code) {
|
function getOpacity(code) {
|
||||||
return code === 'AQ' ? '#ffffff' : strokeColor;
|
return code === 'AQ' ? 0 : 1;
|
||||||
}
|
|
||||||
|
|
||||||
function getHoverColor(code) {
|
|
||||||
return code === 'AQ' ? '#ffffff' : hoverColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleHover({ ISO_A2: code, NAME: name }) {
|
function handleHover({ ISO_A2: code, NAME: name }) {
|
||||||
|
if (code === 'AQ') return;
|
||||||
const country = data?.find(({ x }) => x === code);
|
const country = data?.find(({ x }) => x === code);
|
||||||
setTooltip(`${name}: ${country?.y || 0} visitors`);
|
setTooltip(`${name}: ${country?.y || 0} visitors`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.container, className)}>
|
<div
|
||||||
<ComposableMap data-tip="" projection="geoMercator">
|
className={classNames(styles.container, className)}
|
||||||
|
data-tip=""
|
||||||
|
data-for="world-map-tooltip"
|
||||||
|
>
|
||||||
|
<ComposableMap projection="geoMercator">
|
||||||
<ZoomableGroup zoom={0.8} minZoom={0.7} center={[0, 40]}>
|
<ZoomableGroup zoom={0.8} minZoom={0.7} center={[0, 40]}>
|
||||||
<Geographies geography={geoUrl}>
|
<Geographies geography={geoUrl}>
|
||||||
{({ geographies }) => {
|
{({ geographies }) => {
|
||||||
@ -50,10 +63,11 @@ export default function WorldMap({
|
|||||||
key={geo.rsmKey}
|
key={geo.rsmKey}
|
||||||
geography={geo}
|
geography={geo}
|
||||||
fill={getFillColor(code)}
|
fill={getFillColor(code)}
|
||||||
stroke={getStrokeColor(code)}
|
stroke={colors.strokeColor}
|
||||||
|
opacity={getOpacity(code)}
|
||||||
style={{
|
style={{
|
||||||
default: { outline: 'none' },
|
default: { outline: 'none' },
|
||||||
hover: { outline: 'none', fill: getHoverColor(code) },
|
hover: { outline: 'none', fill: colors.hoverColor },
|
||||||
pressed: { outline: 'none' },
|
pressed: { outline: 'none' },
|
||||||
}}
|
}}
|
||||||
onMouseOver={() => handleHover(geo.properties)}
|
onMouseOver={() => handleHover(geo.properties)}
|
||||||
@ -65,7 +79,7 @@ export default function WorldMap({
|
|||||||
</Geographies>
|
</Geographies>
|
||||||
</ZoomableGroup>
|
</ZoomableGroup>
|
||||||
</ComposableMap>
|
</ComposableMap>
|
||||||
<ReactTooltip>{tooltip}</ReactTooltip>
|
<ReactTooltip id="world-map-tooltip">{tooltip}</ReactTooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
.container {
|
.container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: #fff;
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import Button from 'components/common/Button';
|
|||||||
import { FormButtons } from 'components/layout/FormLayout';
|
import { FormButtons } from 'components/layout/FormLayout';
|
||||||
import { getDateRangeValues } from 'lib/date';
|
import { getDateRangeValues } from 'lib/date';
|
||||||
import styles from './DatePickerForm.module.css';
|
import styles from './DatePickerForm.module.css';
|
||||||
import ButtonGroup from '../common/ButtonGroup';
|
import ButtonGroup from 'components/common/ButtonGroup';
|
||||||
|
|
||||||
const FILTER_DAY = 0;
|
const FILTER_DAY = 0;
|
||||||
const FILTER_RANGE = 1;
|
const FILTER_RANGE = 1;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.msg {
|
.msg {
|
||||||
color: var(--gray50);
|
color: var(--msgColor);
|
||||||
background: var(--red400);
|
background: var(--red400);
|
||||||
font-size: var(--font-size-small);
|
font-size: var(--font-size-small);
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
|
@ -3,11 +3,12 @@ import { FormattedMessage } from 'react-intl';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
import UserButton from '../common/UserButton';
|
import UserButton from 'components/common/UserButton';
|
||||||
import Icon from '../common/Icon';
|
import Icon from 'components/common/Icon';
|
||||||
|
import LanguageButton from 'components/settings/LanguageButton';
|
||||||
|
import ThemeButton from 'components/settings/ThemeButton';
|
||||||
import Logo from 'assets/logo.svg';
|
import Logo from 'assets/logo.svg';
|
||||||
import styles from './Header.module.css';
|
import styles from './Header.module.css';
|
||||||
import LanguageButton from '../common/LanguageButton';
|
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const user = useSelector(state => state.user);
|
const user = useSelector(state => state.user);
|
||||||
@ -32,10 +33,14 @@ export default function Header() {
|
|||||||
<FormattedMessage id="label.settings" defaultMessage="Settings" />
|
<FormattedMessage id="label.settings" defaultMessage="Settings" />
|
||||||
</Link>
|
</Link>
|
||||||
<LanguageButton menuAlign="right" />
|
<LanguageButton menuAlign="right" />
|
||||||
|
<ThemeButton />
|
||||||
<UserButton />
|
<UserButton />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<LanguageButton menuAlign="right" />
|
<>
|
||||||
|
<LanguageButton menuAlign="right" />
|
||||||
|
<ThemeButton />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,8 +16,8 @@ export default function Layout({ title, children, header = true, footer = true }
|
|||||||
</Head>
|
</Head>
|
||||||
{header && <Header />}
|
{header && <Header />}
|
||||||
<main className="container">{children}</main>
|
<main className="container">{children}</main>
|
||||||
<div id="__modals" />
|
|
||||||
{footer && <Footer />}
|
{footer && <Footer />}
|
||||||
|
<div id="__modals" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
6
components/layout/Layout.module.css
Normal file
6
components/layout/Layout.module.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
@ -6,6 +6,8 @@ import { formatLongNumber } from 'lib/format';
|
|||||||
import { dateFormat } from 'lib/lang';
|
import { dateFormat } from 'lib/lang';
|
||||||
import useLocale from 'hooks/useLocale';
|
import useLocale from 'hooks/useLocale';
|
||||||
import styles from './BarChart.module.css';
|
import styles from './BarChart.module.css';
|
||||||
|
import useTheme from 'hooks/useTheme';
|
||||||
|
import { THEME_COLORS } from 'lib/constants';
|
||||||
|
|
||||||
export default function BarChart({
|
export default function BarChart({
|
||||||
chartId,
|
chartId,
|
||||||
@ -23,6 +25,12 @@ export default function BarChart({
|
|||||||
const chart = useRef();
|
const chart = useRef();
|
||||||
const [tooltip, setTooltip] = useState({});
|
const [tooltip, setTooltip] = useState({});
|
||||||
const [locale] = useLocale();
|
const [locale] = useLocale();
|
||||||
|
const [theme] = useTheme();
|
||||||
|
const colors = {
|
||||||
|
text: THEME_COLORS[theme].gray700,
|
||||||
|
line: THEME_COLORS[theme].gray200,
|
||||||
|
zeroLine: THEME_COLORS[theme].gray500,
|
||||||
|
};
|
||||||
|
|
||||||
function renderXLabel(label, index, values) {
|
function renderXLabel(label, index, values) {
|
||||||
const d = new Date(values[index].value);
|
const d = new Date(values[index].value);
|
||||||
@ -97,6 +105,11 @@ export default function BarChart({
|
|||||||
responsive: true,
|
responsive: true,
|
||||||
responsiveAnimationDuration: 0,
|
responsiveAnimationDuration: 0,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
|
legend: {
|
||||||
|
labels: {
|
||||||
|
fontColor: colors.text,
|
||||||
|
},
|
||||||
|
},
|
||||||
scales: {
|
scales: {
|
||||||
xAxes: [
|
xAxes: [
|
||||||
{
|
{
|
||||||
@ -110,6 +123,7 @@ export default function BarChart({
|
|||||||
callback: renderXLabel,
|
callback: renderXLabel,
|
||||||
minRotation: 0,
|
minRotation: 0,
|
||||||
maxRotation: 0,
|
maxRotation: 0,
|
||||||
|
fontColor: colors.text,
|
||||||
},
|
},
|
||||||
gridLines: {
|
gridLines: {
|
||||||
display: false,
|
display: false,
|
||||||
@ -123,6 +137,11 @@ export default function BarChart({
|
|||||||
ticks: {
|
ticks: {
|
||||||
callback: renderYLabel,
|
callback: renderYLabel,
|
||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
|
fontColor: colors.text,
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
color: colors.line,
|
||||||
|
zeroLineColor: colors.zeroLine,
|
||||||
},
|
},
|
||||||
stacked,
|
stacked,
|
||||||
},
|
},
|
||||||
@ -144,8 +163,13 @@ export default function BarChart({
|
|||||||
function updateChart() {
|
function updateChart() {
|
||||||
const { options } = chart.current;
|
const { options } = chart.current;
|
||||||
|
|
||||||
|
options.legend.labels.fontColor = colors.text;
|
||||||
options.scales.xAxes[0].time.unit = unit;
|
options.scales.xAxes[0].time.unit = unit;
|
||||||
options.scales.xAxes[0].ticks.callback = renderXLabel;
|
options.scales.xAxes[0].ticks.callback = renderXLabel;
|
||||||
|
options.scales.xAxes[0].ticks.fontColor = colors.text;
|
||||||
|
options.scales.yAxes[0].ticks.fontColor = colors.text;
|
||||||
|
options.scales.yAxes[0].gridLines.color = colors.line;
|
||||||
|
options.scales.yAxes[0].gridLines.zeroLineColor = colors.zeroLine;
|
||||||
options.animation.duration = animationDuration;
|
options.animation.duration = animationDuration;
|
||||||
options.tooltips.custom = renderTooltip;
|
options.tooltips.custom = renderTooltip;
|
||||||
|
|
||||||
@ -161,7 +185,7 @@ export default function BarChart({
|
|||||||
updateChart();
|
updateChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [datasets, unit, animationDuration, locale]);
|
}, [datasets, unit, animationDuration, locale, theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tooltip {
|
.tooltip {
|
||||||
|
color: var(--msgColor);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
@ -12,7 +13,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: var(--gray50);
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
color: #6e6e6e;
|
color: #6e6e6e;
|
||||||
border-left: 1px solid var(--gray600);
|
border-left: 1px solid var(--gray500);
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useRef } from 'react';
|
import React, { useState, useRef } from 'react';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import Menu from './Menu';
|
import Menu from 'components/common/Menu';
|
||||||
import Button from './Button';
|
import Button from 'components/common/Button';
|
||||||
import { menuOptions } from 'lib/lang';
|
import { menuOptions } from 'lib/lang';
|
||||||
import useLocale from 'hooks/useLocale';
|
import useLocale from 'hooks/useLocale';
|
||||||
import useDocumentClick from 'hooks/useDocumentClick';
|
import useDocumentClick from 'hooks/useDocumentClick';
|
13
components/settings/ThemeButton.js
Normal file
13
components/settings/ThemeButton.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Button from 'components/common/Button';
|
||||||
|
import useTheme from 'hooks/useTheme';
|
||||||
|
|
||||||
|
export default function ThemeButton() {
|
||||||
|
const [theme, setTheme] = useTheme();
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
setTheme(theme === 'light' ? 'dark' : 'light');
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Button onClick={handleClick}>{theme}</Button>;
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { listTimeZones } from 'timezone-support';
|
import { listTimeZones } from 'timezone-support';
|
||||||
import DropDown from '../common/DropDown';
|
import DropDown from 'components/common/DropDown';
|
||||||
import Button from '../common/Button';
|
import Button from 'components/common/Button';
|
||||||
import useTimezone from 'hooks/useTimezone';
|
import useTimezone from 'hooks/useTimezone';
|
||||||
import { getTimezone } from 'lib/date';
|
import { getTimezone } from 'lib/date';
|
||||||
import styles from './TimezoneSetting.module.css';
|
import styles from './TimezoneSetting.module.css';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { updateApp } from 'redux/actions/app';
|
import { setLocale } from 'redux/actions/app';
|
||||||
import { setItem } from 'lib/web';
|
import { setItem } from 'lib/web';
|
||||||
import { LOCALE_CONFIG } from 'lib/constants';
|
import { LOCALE_CONFIG } from 'lib/constants';
|
||||||
|
|
||||||
@ -7,10 +7,10 @@ export default function useLocale() {
|
|||||||
const locale = useSelector(state => state.app.locale);
|
const locale = useSelector(state => state.app.locale);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
function setLocale(value) {
|
function saveLocale(value) {
|
||||||
setItem(LOCALE_CONFIG, value);
|
setItem(LOCALE_CONFIG, value);
|
||||||
dispatch(updateApp({ locale: value }));
|
dispatch(setLocale(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [locale, setLocale];
|
return [locale, saveLocale];
|
||||||
}
|
}
|
||||||
|
21
hooks/useTheme.js
Normal file
21
hooks/useTheme.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { setTheme } from 'redux/actions/app';
|
||||||
|
import { getItem, setItem } from 'lib/web';
|
||||||
|
import { THEME_CONFIG } from 'lib/constants';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
export default function useLocale() {
|
||||||
|
const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || 'light');
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
function saveTheme(value) {
|
||||||
|
setItem(THEME_CONFIG, value);
|
||||||
|
dispatch(setTheme(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.body.setAttribute('data-theme', theme);
|
||||||
|
}, [theme]);
|
||||||
|
|
||||||
|
return [theme, saveTheme];
|
||||||
|
}
|
@ -2,6 +2,38 @@ export const AUTH_COOKIE_NAME = 'umami.auth';
|
|||||||
export const LOCALE_CONFIG = 'umami.locale';
|
export const LOCALE_CONFIG = 'umami.locale';
|
||||||
export const TIMEZONE_CONFIG = 'umami.timezone';
|
export const TIMEZONE_CONFIG = 'umami.timezone';
|
||||||
export const DATE_RANGE_CONFIG = 'umami.date-range';
|
export const DATE_RANGE_CONFIG = 'umami.date-range';
|
||||||
|
export const THEME_CONFIG = 'umami.theme';
|
||||||
|
|
||||||
|
export const THEME_COLORS = {
|
||||||
|
light: {
|
||||||
|
primary: '#2680eb',
|
||||||
|
gray50: '#ffffff',
|
||||||
|
gray75: '#fafafa',
|
||||||
|
gray100: '#f5f5f5',
|
||||||
|
gray200: '#eaeaea',
|
||||||
|
gray300: '#e1e1e1',
|
||||||
|
gray400: '#cacaca',
|
||||||
|
gray500: '#b3b3b3',
|
||||||
|
gray600: '#8e8e8e',
|
||||||
|
gray700: '#6e6e6e',
|
||||||
|
gray800: '#4b4b4b',
|
||||||
|
gray900: '#2c2c2c',
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
primary: '#2680eb',
|
||||||
|
gray50: '#252525',
|
||||||
|
gray75: '#2f2f2f',
|
||||||
|
gray100: '#323232',
|
||||||
|
gray200: '#3e3e3e',
|
||||||
|
gray300: '#4a4a4a',
|
||||||
|
gray400: '#5a5a5a',
|
||||||
|
gray500: '#6e6e6e',
|
||||||
|
gray600: '#909090',
|
||||||
|
gray700: '#b9b9b9',
|
||||||
|
gray800: '#e3e3e3',
|
||||||
|
gray900: '#ffffff',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const DEFAULT_DATE_RANGE = '24hour';
|
export const DEFAULT_DATE_RANGE = '24hour';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.42.0",
|
"version": "0.43.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { getItem } from 'lib/web';
|
import { getItem } from 'lib/web';
|
||||||
import { LOCALE_CONFIG } from 'lib/constants';
|
import { LOCALE_CONFIG, THEME_CONFIG } from 'lib/constants';
|
||||||
|
|
||||||
const app = createSlice({
|
const app = createSlice({
|
||||||
name: 'app',
|
name: 'app',
|
||||||
initialState: { locale: getItem(LOCALE_CONFIG) || 'en-US' },
|
initialState: {
|
||||||
|
locale: getItem(LOCALE_CONFIG) || 'en-US',
|
||||||
|
theme: getItem(THEME_CONFIG) || 'light',
|
||||||
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
updateApp(state, action) {
|
setLocale(state, action) {
|
||||||
state = action.payload;
|
state.locale = action.payload;
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
setTheme(state, action) {
|
||||||
|
state.theme = action.payload;
|
||||||
return state;
|
return state;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { updateApp } = app.actions;
|
export const { setLocale, setTheme } = app.actions;
|
||||||
|
|
||||||
export default app.reducer;
|
export default app.reducer;
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
|
font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||||
font-size: var(--font-size-normal);
|
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
font-size: var(--font-size-normal);
|
||||||
color: var(--gray900);
|
color: var(--gray900);
|
||||||
background: var(--gray75);
|
background: var(--gray75);
|
||||||
}
|
}
|
||||||
@ -51,6 +54,8 @@ a:visited {
|
|||||||
input[type='text'],
|
input[type='text'],
|
||||||
input[type='password'],
|
input[type='password'],
|
||||||
textarea {
|
textarea {
|
||||||
|
color: var(--gray900);
|
||||||
|
background: var(--gray50);
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
font-size: var(--font-size-normal);
|
font-size: var(--font-size-normal);
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
@ -92,6 +97,7 @@ main {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#__modals {
|
#__modals {
|
||||||
|
@ -36,4 +36,33 @@
|
|||||||
--green500: #268e6c;
|
--green500: #268e6c;
|
||||||
--green600: #12805c;
|
--green600: #12805c;
|
||||||
--green700: #107154;
|
--green700: #107154;
|
||||||
|
|
||||||
|
--msgColor: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='dark'] {
|
||||||
|
/*
|
||||||
|
--gray50: #080808;
|
||||||
|
--gray75: #1a1a1a;
|
||||||
|
--gray100: #1e1e1e;
|
||||||
|
--gray200: #2c2c2c;
|
||||||
|
--gray300: #393939;
|
||||||
|
--gray400: #494949;
|
||||||
|
--gray500: #5c5c5c;
|
||||||
|
--gray600: #7c7c7c;
|
||||||
|
--gray700: #6e6e6e;
|
||||||
|
--gray800: #a2a2a2;
|
||||||
|
--gray900: #efefef;
|
||||||
|
*/
|
||||||
|
--gray50: #252525;
|
||||||
|
--gray75: #2f2f2f;
|
||||||
|
--gray100: #323232;
|
||||||
|
--gray200: #3e3e3e;
|
||||||
|
--gray300: #4a4a4a;
|
||||||
|
--gray400: #5a5a5a;
|
||||||
|
--gray500: #6e6e6e;
|
||||||
|
--gray600: #909090;
|
||||||
|
--gray700: #b9b9b9;
|
||||||
|
--gray800: #e3e3e3;
|
||||||
|
--gray900: #ffffff;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user