Skip to content

Commit

Permalink
Dark Theme\nCloses (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Jun 27, 2022
1 parent 029f1f6 commit ac48903
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const appConfig = new Store({
},
sourceList: DefaultSourceList,
lolDirHasCJKChar: false,
darkTheme: false,
darkTheme: true,
alwaysRequestLatestVersion: false,
enableChinaCDN: false,
startMinimized: false,
Expand Down
11 changes: 11 additions & 0 deletions src/DarkTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createTheme, darkThemePrimitives, DarkTheme } from 'baseui';

const overrides = {
colors: {
...DarkTheme.colors,
background: '#1a1c1f',
color: '#ffffff',
},
};

export const darkTheme = createTheme(darkThemePrimitives, overrides);
5 changes: 3 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HashRouter as Router, Switch, Route } from 'react-router-dom';

import { Client as Styletron } from 'styletron-engine-atomic';
import { Provider as StyletronProvider } from 'styletron-react';
import { DarkTheme, LightTheme, BaseProvider } from 'baseui';
import { LightTheme, BaseProvider } from 'baseui';
import { SnackbarProvider, PLACEMENT } from 'baseui/snackbar';

import AppContext from 'src/share/context';
Expand All @@ -16,6 +16,7 @@ import Toolbar from 'src/components/toolbar';
import Home from 'src/modules/home';
import Import from 'src/modules/import';
import Settings from 'src/modules/settings';
import { darkTheme } from './DarkTheme';

const engine = new Styletron();

Expand Down Expand Up @@ -63,7 +64,7 @@ const App = () => {
<AppContext.Provider value={contextValue}>
<StyletronProvider value={engine}>
<BaseProvider
theme={window.bridge.appConfig.get('darkTheme', false) ? DarkTheme : LightTheme}>
theme={window.bridge.appConfig.get('darkTheme', true) ? darkTheme : LightTheme}>
<SnackbarProvider
placement={PLACEMENT.bottom}
overrides={{
Expand Down
8 changes: 8 additions & 0 deletions src/components/footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export default function Footer() {
};

return (
// <div className={
// cn(s.footer,
// css({
// backgroundColor: theme.colors.background,
// color: theme.colors.primary,
// }),
// )}
//>
<div className={s.footer}>
{process.env.IS_DEV
? `dev`
Expand Down
19 changes: 16 additions & 3 deletions src/components/perk-showcase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Zap } from 'react-feather';

import { IRuneItem } from '@interfaces/commonTypes';
import { MainStyleIds } from 'src/share/constants/runes';
import { useStyletron } from 'baseui';

interface IProps {
isAramMode?: boolean;
Expand All @@ -32,7 +33,7 @@ export default function PerkShowcase({
const { primaryStyleId, subStyleId, selectedPerkIds } = perk;
const pId = selectedPerkIds.find((i) => MainStyleIds[primaryStyleId].includes(+i));
const el = useRef(null);

const [css, theme] = useStyletron();
const shouldShowStatistics = perk.winRate?.length > 0 && perk.pickCount > 0;

const displayPosition = (position = ``) => {
Expand All @@ -47,7 +48,13 @@ export default function PerkShowcase({

return (
<div
className={s.item}
className={
cn(
s.item,
css ({
backgroundColor: theme.colors.background,
}),
)}
ref={el}
onMouseEnter={() => onMouseEnter(perk, el.current)}
onMouseLeave={onMouseLeave}>
Expand All @@ -71,7 +78,13 @@ export default function PerkShowcase({
)}
</div>

<div className={s.apply} title={t(`apply perk`)} onClick={onApply}>
<div className={
cn(
s.apply,
css ({
backgroundColor: theme.colors.background,
}),
)} title={t(`apply perk`)} onClick={onApply}>
<Zap color={`#21A453`} size={36} />
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/components/perk-showcase/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
user-select: none;

&:hover {
background-color: #f6f6f6;
cursor: pointer;
}

Expand Down Expand Up @@ -69,7 +68,6 @@
display: flex;
justify-content: center;
align-items: center;
background: #ffffff;
-webkit-app-region: no-drag;
//transition: all linear 0.2s;

Expand Down
19 changes: 16 additions & 3 deletions src/components/rune-preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import cn from 'classnames';

import { MainRuneMap, SubRuneMap, FragmentMap } from 'src/share/constants/runes';
import { IRuneItem, ICSSProperties, ICoordinate } from '@interfaces/commonTypes';
import { useStyletron } from 'baseui';

interface IProps {
perk: IRuneItem | null;
coordinate: ICoordinate;
}

export default function RunePreview({ perk, coordinate }: IProps) {
const [css, theme] = useStyletron();
const { primaryStyleId = 0, subStyleId = 0, selectedPerkIds } = perk ?? {
primaryStyleId: 0,
subStyleId: 0,
Expand Down Expand Up @@ -40,7 +42,11 @@ export default function RunePreview({ perk, coordinate }: IProps) {
}

return (
<div key={id} className={cn(s.runeImg, s[`rune-${id}`], selected && s.selected)} />
<div key={id} className={cn(s.runeImg, s[`rune-${id}`], selected && s.selected,
css ({
backgroundColor: theme.colors.background,
}),
)} />
);
})}
</div>
Expand All @@ -63,9 +69,16 @@ export default function RunePreview({ perk, coordinate }: IProps) {
};

return ReactDOM.createPortal(
<div style={style} className={cn(s.main, up && s.up)}>
<div style={style} className={cn(s.main, up && s.up,
css ({
backgroundColor: theme.colors.background,
}),
)}>
<span className={cn(s.bot, s.triangle)} />
<span className={cn(s.top, s.triangle)} />
<span className={cn(s.top, s.triangle, css ({
borderColor: ( theme.colors.background ),
}),
)} />
<div className={s.col}>{mainIds.map(renderRow())}</div>
<div className={s.col}>{subIds.map(renderRow())}</div>
<div className={cn(s.col, s.fragment)}>{FragmentMap.map(renderRow(true))}</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/rune-preview/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ $imgGap: 0.4ex;
border-radius: 4px;
transition: top 0.1s linear;
box-shadow: 0 2px 16px rgba(0, 0, 0, 0.28);
background-color: #ffffff;
display: flex;

.col {
Expand Down Expand Up @@ -95,7 +94,7 @@ $imgGap: 0.4ex;
}

&.top {
border-color: #f6f6f6 transparent transparent;
border-color: transparent transparent;
top: $topOffset;
}
}
Expand Down
30 changes: 25 additions & 5 deletions src/components/toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import s from './style.module.scss';
import React from 'react';
import { useHistory } from 'react-router-dom';
import { useTranslation } from 'react-i18next';

import cn from 'classnames';
import { StatefulTooltip } from 'baseui/tooltip';
import { Settings, Minimize2, X } from 'react-feather';
import { useStyletron } from 'baseui';

const Toolbar = () => {
const [t] = useTranslation();
const history = useHistory();

const [css, theme] = useStyletron();

const onHide = () => {
window.bridge.sendMessage(`toggle-main-window`);
};
Expand All @@ -21,19 +23,37 @@ const Toolbar = () => {
return (
<div className={s.toolbar}>
<StatefulTooltip accessibilityType={'tooltip'} content={t(`minimize`)}>
<span className={s.icon} onClick={onHide}>
<span className={
cn(s.icon,
css({
color: theme.colors.primary,
}),
)}
onClick={onHide}>
<Minimize2 size={16} />
</span>
</StatefulTooltip>

<StatefulTooltip accessibilityType={'tooltip'} content={t(`settings`)}>
<span className={s.icon} onClick={() => history.replace(`/settings`)}>
<span className={
cn(s.icon,
css({
color: theme.colors.primary,
}),
)}
onClick={() => history.replace(`/settings`)}>
<Settings size={16} />
</span>
</StatefulTooltip>

<StatefulTooltip accessibilityType={'tooltip'} content={t(`close`)}>
<span className={s.icon} onClick={onClose}>
<span className={
cn(s.icon,
css({
color: theme.colors.primary,
}),
)}
onClick={onClose}>
<X size={16} />
</span>
</StatefulTooltip>
Expand Down
1 change: 0 additions & 1 deletion src/components/toolbar/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
-webkit-app-region: no-drag;

&:hover {
background-color: #e2e2e2;
cursor: pointer;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
html {
height: 100vh;
font-size: 16px;
background-color: #1a1c1f;
}

body {
Expand Down
15 changes: 14 additions & 1 deletion src/modules/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,20 @@ export default function Home({ onDirChange = _noop }: IProps) {
!store.version || !lolDir || !selectedSources.length || fetchingSources;

return (
<div className={s.container}>
//className={cn(
// s.folderTip,
// css({
// backgroundColor: theme.colors.backgroundLightWarning,
// borderRadius: theme.borders.radius300,
// }),
//)}
<div className={cn(
s.container,
css({
backgroundColor: theme.colors.background,
color: theme.colors.primary,
}),
)}>
<h1 className={s.title}>
<img src={logo} alt='' />
<span>ChampR</span>
Expand Down
31 changes: 27 additions & 4 deletions src/modules/popup/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ReactComponent as PinIcon } from 'src/assets/icons/push-pin.svg';
import { IChampionInfo, IRuneItem, ICoordinate } from '@interfaces/commonTypes';
import { makeChampMap } from './utils';
import { createIpcPromise } from 'src/service/ipc';
import cn from 'classnames';

const Pin = styled(`button`, () => ({
margin: `0 2ex 0 0`,
Expand Down Expand Up @@ -54,7 +55,7 @@ const getInitTab = () => {

export function Content() {
const [t] = useTranslation();
const [, theme] = useStyletron();
const [css, theme] = useStyletron();
const sourceList: ISourceItem[] = window.bridge.appConfig.get(`sourceList`);

const [activeTab, setActiveTab] = useState<ISourceItem[]>(getInitTab());
Expand Down Expand Up @@ -235,7 +236,15 @@ export function Content() {
const source = sourceList.find((i) => i.value === pkgName);

return (
<div className={s.main}>
<div className={
cn(
s.main,
css ({
backgroundColor: theme.colors.background,
}),
)
}
>
{championDetail && (
<div className={s.drag}>
<StatefulPopover content={t(`pin/unpin`)} triggerType={TRIGGER_TYPE.hover}>
Expand All @@ -245,7 +254,12 @@ export function Content() {
</StatefulPopover>

<StatefulPopover content={t(`hide`)} triggerType={TRIGGER_TYPE.hover}>
<button className={s.close} onClick={onClose}>
<button className={cn(s.close, css(
{
backgroundColor: theme.colors.background,
},
))
} onClick={onClose}>
<X size={26} color={`#EA4C89`} />
</button>
</StatefulPopover>
Expand Down Expand Up @@ -294,7 +308,16 @@ export function Content() {
)}

{perkList[tabIdx] && (
<div className={s.list}>
<div className={
cn(
s.list,
css ({
color: theme.colors.primary,
backgroundColor: theme.colors.background,
}),
)
}
>
{renderList(perkList[tabIdx], source?.isAram, source?.isURF)}
</div>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useEffect } from 'react';

import { Client as Styletron } from 'styletron-engine-atomic';
import { Provider as StyletronProvider } from 'styletron-react';
import { DarkTheme, LightTheme, BaseProvider } from 'baseui';
import { LightTheme, BaseProvider } from 'baseui';
import initI18n from 'src/modules/i18n';
import { Content } from './content';
import { darkTheme } from 'src/DarkTheme';

initI18n();
const engine = new Styletron();
Expand All @@ -17,7 +18,7 @@ export default function Popup() {
return (
<StyletronProvider value={engine}>
<BaseProvider
theme={window.bridge.appConfig.get('darkTheme', false) ? DarkTheme : LightTheme}>
theme={window.bridge.appConfig.get('darkTheme', true) ? darkTheme : LightTheme}>
<Content />
</BaseProvider>
</StyletronProvider>
Expand Down
Loading

0 comments on commit ac48903

Please sign in to comment.