Skip to content

Commit

Permalink
feat: add white theme
Browse files Browse the repository at this point in the history
  • Loading branch information
notmedia committed Aug 17, 2022
1 parent 00204d5 commit 1603446
Show file tree
Hide file tree
Showing 16 changed files with 904 additions and 642 deletions.
1,315 changes: 723 additions & 592 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@
},
"devDependencies": {
"@babel/core": "7.18.10",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@commitlint/cli": "17.0.3",
"@commitlint/config-conventional": "17.0.3",
"@electron-forge/cli": "6.0.0-beta.65",
"@electron-forge/maker-deb": "6.0.0-beta.65",
"@electron-forge/maker-rpm": "6.0.0-beta.65",
"@electron-forge/maker-squirrel": "6.0.0-beta.65",
"@electron-forge/maker-zip": "6.0.0-beta.65",
"@electron-forge/plugin-webpack": "6.0.0-beta.65",
"@electron-forge/publisher-github": "^6.0.0-beta.65",
"@release-it/conventional-changelog": "^5.0.0",
"@electron-forge/publisher-github": "6.0.0-beta.65",
"@release-it/conventional-changelog": "5.0.0",
"@storybook/addon-actions": "6.5.10",
"@storybook/addon-essentials": "6.5.10",
"@storybook/addon-interactions": "6.5.10",
Expand Down Expand Up @@ -106,7 +106,7 @@
"jest": "28.1.3",
"node-loader": "2.0.0",
"prettier": "2.7.1",
"release-it": "^15.3.0",
"release-it": "15.3.0",
"style-loader": "3.3.1",
"ts-jest": "28.0.8",
"ts-loader": "9.3.1",
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { ThemeType, useSettingsStore } from './storage';
import { DarkTheme, globalStyles, LightTheme } from './themes';

function App(): JSX.Element {
const theme = useSettingsStore((store) => store.type) === ThemeType.Dark ? DarkTheme : LightTheme;
const theme =
useSettingsStore((store) => store.theme) === ThemeType.Dark ? DarkTheme : LightTheme;

globalStyles();

Expand Down
2 changes: 2 additions & 0 deletions src/app/components/select/select.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export const StyledSelect = styled(ReactSelect, {
backgroundColor: '$accents0',
},
'.react-select__option:hover': {
color: '$text',
backgroundColor: '$accents2',
},
'.react-select__option--is-selected': {
color: '$text',
backgroundColor: '$accents1',
},

Expand Down
59 changes: 30 additions & 29 deletions src/app/pages/header.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import { faSquarePlus } from '@fortawesome/free-solid-svg-icons';
import { faCog, faSquarePlus } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Button, styled } from '@nextui-org/react';
import { Button, Container } from '@nextui-org/react';
import React from 'react';

// import { useLogsStore } from '../storage';
import { CreateCollectionModal } from './collections';
// import { LogsButton, LogsModal } from './logs';

const HeaderWrapper = styled('div', {
display: 'flex',
flexWrap: 'nowrap',
justifyContent: 'center',
alignItems: 'center',
overflow: 'hidden',
});
import { UpdateSettingsModal } from './settings';

export const Header: React.FC = () => {
const [createCollectionModalVisible, setCreateCollectionModalVisible] = React.useState(false);
// const [logsModalVisible, setLogsModalVisible] = React.useState(false);
// const { newLogsAvailable, markAsReadLogs } = useLogsStore((store) => store);

// const handleLogsButtonClick = () => {
// setLogsModalVisible(true);
// markAsReadLogs();
// };
const [updateSettingsModalVisible, setUpdateSettingsModalVisible] = React.useState(false);

return (
<HeaderWrapper>
{/* <LogsButton badgeVisible={newLogsAvailable} onClick={handleLogsButtonClick} />
<Spacer /> */}
<Container fluid display="flex" wrap="nowrap" justify="center" alignItems="center">
<Button
auto
bordered
Expand All @@ -37,22 +20,40 @@ export const Header: React.FC = () => {
size="sm"
icon={<FontAwesomeIcon icon={faSquarePlus} />}
onClick={() => setCreateCollectionModalVisible(true)}
css={{
marginLeft: 'auto',
}}
>
New collection
</Button>
<Button
auto
light
size="xs"
color="warning"
css={{
marginLeft: 'auto',
minWidth: 10,
color: '$accents9',
'&:hover': {
color: '$warning',
backgroundColor: '$accents0',
},
}}
icon={<FontAwesomeIcon icon={faCog} />}
onClick={() => setUpdateSettingsModalVisible(true)}
/>
<CreateCollectionModal
fullScreen
closeButton
open={createCollectionModalVisible}
onClose={() => setCreateCollectionModalVisible(false)}
/>
{/* <LogsModal
open={logsModalVisible}
<UpdateSettingsModal
closeButton
fullScreen
scroll
onClose={() => setLogsModalVisible(false)}
/> */}
</HeaderWrapper>
open={updateSettingsModalVisible}
onClose={() => setUpdateSettingsModalVisible(false)}
/>
</Container>
);
};
1 change: 1 addition & 0 deletions src/app/pages/settings/forms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './settings.form';
58 changes: 58 additions & 0 deletions src/app/pages/settings/forms/settings.form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Container, Dropdown } from '@nextui-org/react';
import React from 'react';
import { Controller, useForm } from 'react-hook-form';

import { Settings, ThemeType } from '../../../storage';

export interface SettingsFormProps {
id?: string;

defaultValues?: Partial<Settings>;

onSubmit: (payload: Settings) => void;
}

export const SettingsForm: React.FC<SettingsFormProps> = ({
onSubmit = () => {},
id,
defaultValues,
}) => {
const { handleSubmit, control } = useForm<Settings>({ defaultValues });

return (
<form id={id} onSubmit={handleSubmit(onSubmit)}>
<Container gap={0} display="flex" direction="column" justify="center">
<Controller
name="theme"
control={control}
render={({ field }) => (
<Dropdown disableAnimation>
<Dropdown.Button
bordered
borderWeight="light"
animated={false}
color="gradient"
css={{ tt: 'capitalize' }}
>
{field.value} Theme
</Dropdown.Button>
<Dropdown.Menu
aria-label="theme"
color="primary"
disallowEmptySelection
selectionMode="single"
defaultSelectedKeys={defaultValues?.theme}
onSelectionChange={(keys) => {
field.onChange(Array.from(keys).join(''));
}}
>
<Dropdown.Item key={ThemeType.Light}>Light</Dropdown.Item>
<Dropdown.Item key={ThemeType.Dark}>Dark</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
)}
/>
</Container>
</form>
);
};
1 change: 1 addition & 0 deletions src/app/pages/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './modals';
1 change: 1 addition & 0 deletions src/app/pages/settings/modals/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './update-settings.modal';
50 changes: 50 additions & 0 deletions src/app/pages/settings/modals/update-settings.modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Button, Modal, ModalProps, Text } from '@nextui-org/react';
import React from 'react';

import { Settings, useSettingsStore } from '../../../storage';
import { SettingsForm } from '../forms';

export const UpdateSettingsModal: React.FC<ModalProps> = ({ onClose = () => {}, ...props }) => {
const { updateTheme, theme } = useSettingsStore((store) => store);

const handleSubmit = async (payload: Partial<Settings>) => {
if (payload.theme) {
await updateTheme(payload.theme);
}

onClose();
};

return (
<Modal {...props} onClose={onClose} aria-labelledby="update-settings-modal">
<Modal.Header css={{ userSelect: 'none' }}>
<Text>Settings</Text>
</Modal.Header>
<Modal.Body>
<SettingsForm
id="update-settings-form"
defaultValues={{
theme,
}}
onSubmit={handleSubmit}
/>
</Modal.Body>
<Modal.Footer>
<Button auto bordered borderWeight="light" size="sm" color="error" onClick={onClose}>
Cancel
</Button>
<Button
auto
bordered
borderWeight="light"
size="sm"
color="gradient"
type="submit"
form="update-settings-form"
>
Apply
</Button>
</Modal.Footer>
</Modal>
);
};
2 changes: 0 additions & 2 deletions src/app/storage/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export * from './theme.interface';
export * from './settings.interface';
export * from './language.interface';
export * from './collections.interface';
export * from './environments.interface';
export * from './logs.interface';
Expand Down
3 changes: 0 additions & 3 deletions src/app/storage/interfaces/language.interface.ts

This file was deleted.

18 changes: 14 additions & 4 deletions src/app/storage/interfaces/settings.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { Language } from './language.interface';
import { ThemeType } from './theme.interface';
export enum Language {
EN = 'en',
}

export enum ThemeType {
Dark = 'dark',
Light = 'light',
}

export interface SettingsStorage {
type: ThemeType;
export interface Settings {
theme: ThemeType;
language: Language;
}

export interface SettingsStorage extends Settings {
updateTheme: (theme: ThemeType) => void;
}
4 changes: 0 additions & 4 deletions src/app/storage/interfaces/theme.interface.ts

This file was deleted.

14 changes: 12 additions & 2 deletions src/app/storage/settings.storage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
/* eslint-disable no-param-reassign */

import { produce } from 'immer';
import create from 'zustand';
import { persist } from 'zustand/middleware';

import { Language, SettingsStorage, ThemeType } from './interfaces';

export const useSettingsStore = create(
persist<SettingsStorage>(
() => ({
type: ThemeType.Dark,
(set) => ({
theme: ThemeType.Dark,
language: Language.EN,

updateTheme: (theme) =>
set(
produce<SettingsStorage>((state) => {
state.theme = theme;
})
),
}),
{
name: 'settings',
Expand Down
5 changes: 5 additions & 0 deletions src/app/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ import { createTheme } from '@nextui-org/react';

export const LightTheme = createTheme({
type: 'light',
theme: {
colors: {
gradient: 'linear-gradient(112deg, $yellow400 -25%, $yellow600 30%, $cyan600 90%)',
},
},
});

0 comments on commit 1603446

Please sign in to comment.