Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Patriciu Nista committed Apr 29, 2024
1 parent 8741731 commit a8b8ed5
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 248 deletions.
20 changes: 10 additions & 10 deletions packages/yoroi-extension/app/App.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// @flow
import { Component } from 'react';
import type { Node } from 'react';
import type { RouterHistory } from 'react-router-dom';
import type { StoresMap } from './stores';
import type { ActionsMap } from './actions';
import { Component } from 'react';
import { observer } from 'mobx-react';
import { Router } from 'react-router-dom';
import type { RouterHistory } from 'react-router-dom';
import { addLocaleData, IntlProvider } from 'react-intl';
import { observable, autorun, runInAction } from 'mobx';
import { CssBaseline } from '@mui/material';
import { Routes } from './Routes';
import { locales, translations } from './i18n/translations';
import type { StoresMap } from './stores';
import type { ActionsMap } from './actions';
import ThemeManager from './ThemeManager';
import environment from './environment';
import MaintenancePage from './containers/MaintenancePage';
import CrashPage from './containers/CrashPage';
import { Logger } from './utils/logging';
import { LayoutProvider } from './styles/context/layout';
import { ColorModeProvider } from './styles/context/mode';
import { CssBaseline } from '@mui/material';
import { globalStyles } from './styles/globalStyles';
import Support from './components/widgets/Support';
import { changeToplevelTheme, MuiThemes } from './styles/themes';
import ThemeManager from './ThemeManager';
import environment from './environment';
import MaintenancePage from './containers/MaintenancePage';
import CrashPage from './containers/CrashPage';
import Support from './components/widgets/Support';

// https://github.com/yahoo/react-intl/wiki#loading-locale-data
addLocaleData(locales);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,98 +1,90 @@
// @flow
import type { Node } from 'react';
import type { DesignToken } from '../../../styles/globalStyles';
import { Component } from 'react';
import { observer } from 'mobx-react';
import styles from './YoroiPalette.scss'
import type { Node } from 'react';
import { classicTheme } from '../../../styles/themes/classic-theme'
import { modernTheme } from '../../../styles/themes/modern-theme'
import styles from './YoroiPalette.scss';
import { classicTheme } from '../../../styles/themes/legacy/classic-theme';
import { modernTheme } from '../../../styles/themes/legacy/modern-theme';
import classNames from 'classnames';
import { ReactComponent as ArrowDown } from '../../../assets/images/down-arrow.inline.svg';
import { ReactComponent as ArrowDown } from '../../../assets/images/down-arrow.inline.svg';
import { getMainYoroiPalette, formatPalette } from '../../../styles/globalStyles';
import type { DesignToken } from '../../../styles/globalStyles'

/**
* @todos
* 1. Print transaction status
* 2. Print the actual theme object
*/
type Props = {||}
type Props = {||};

type Theme = 'classic' | 'modern'
type Theme = 'classic' | 'modern';

type State = {|
currentTheme: Theme
|}
currentTheme: Theme,
|};

const themes = {
classic: classicTheme,
modern: modernTheme
}
classic: classicTheme,
modern: modernTheme,
};

@observer
export default class YoroiPalettePage extends Component<Props, State> {
state: State = {
currentTheme: 'classic',
};

state: State = {
currentTheme: 'classic',
}

switchTheme(theme: Theme): void {
this.setState({ currentTheme: theme })
}
switchTheme(theme: Theme): void {
this.setState({ currentTheme: theme });
}

render(): Node {
render(): Node {
const { currentTheme } = this.state;
const palette = getMainYoroiPalette(themes[currentTheme]);
const { designTokens, nameToHex } = formatPalette(palette, themes[currentTheme]);
return (
<div className={styles.component}>
<div className={styles.themes}>
<button
className={classNames([currentTheme === 'classic' && styles.active])}
type="button"
onClick={() => this.switchTheme('classic')}
>
Classic Theme
</button>
<button
onClick={() => this.switchTheme('modern')}
className={classNames([currentTheme === 'modern' && styles.active])}
type="button"
>
Modern Theme
</button>
</div>

const { currentTheme } = this.state
const palette = getMainYoroiPalette(themes[currentTheme])
const { designTokens, nameToHex } = formatPalette(palette, themes[currentTheme])
return (
<div className={styles.component}>
<div className={styles.themes}>
<button
className={classNames([(currentTheme === 'classic') && styles.active])}
type='button'
onClick={() => this.switchTheme('classic')}
>
Classic Theme
</button>
<button
onClick={() => this.switchTheme('modern')}
className={classNames([(currentTheme === 'modern') && styles.active])}
type='button'
>
Modern Theme
</button>
<div className={styles.multiLayer}>
<h1>Design tokens</h1>
<div className={styles.multiLayerRows}>
{designTokens.map(color => (
<ul className={styles.multiLayerRow}>{this.renderRow(color).map(node => node)}</ul>
))}
</div>
</div>

<div className={styles.multiLayer}>
<h1>Design tokens</h1>
<div className={styles.multiLayerRows}>
{
designTokens.map(color => (
<ul className={styles.multiLayerRow}>
{this.renderRow(color).map(node => node)}
</ul>
))
}
</div>
<h1 className={styles.nameToHexHeader}>Colors Direct Hex Colors</h1>
{nameToHex.map(color => (
<div className={styles.row} key={color.name}>
<span
className={styles.colorBox}
style={{
backgroundColor: color.hex,
}}
/>
<div className={styles.colorHex}>{String(color.hex)}</div>
<div className={styles.colorName}>{color.name}</div>
</div>

<h1 className={styles.nameToHexHeader}>Colors Direct Hex Colors</h1>
{nameToHex.map((color) => (
<div className={styles.row} key={color.name}>
<span
className={styles.colorBox}
style={{
backgroundColor: color.hex
}}
/>
<div className={styles.colorHex}>
{String(color.hex)}
</div>
<div className={styles.colorName}>{color.name}</div>
</div>
))}
</div>
)
))}
</div>
);
}

renderRow(color: DesignToken): Node[] {
Expand All @@ -103,7 +95,7 @@ export default class YoroiPalettePage extends Component<Props, State> {
},
{
text: color.path.join('-'),
classnames: [styles.flexWithMargin, styles.designTokens]
classnames: [styles.flexWithMargin, styles.designTokens],
},
{
text: color.child,
Expand All @@ -112,13 +104,13 @@ export default class YoroiPalettePage extends Component<Props, State> {
{
text: color.parent,
classnames: [styles.flexWithMargin, styles.parent],
}
]
},
];

const nodes = []
const nodes = [];

for(let i = 0; i < subRows.length; i++) {
const subRow = subRows[i]
for (let i = 0; i < subRows.length; i++) {
const subRow = subRows[i];
nodes.push(
<>
<li className={classNames(subRow.classnames)}>
Expand All @@ -133,11 +125,15 @@ export default class YoroiPalettePage extends Component<Props, State> {
/>
<div>{subRow.text}</div>
</li>
{i < subRows.length -1 && <li className={styles.arrowDown}><ArrowDown /></li>}
{i < subRows.length - 1 && (
<li className={styles.arrowDown}>
<ArrowDown />
</li>
)}
</>
)
);
}

return nodes
return nodes;
}
}
}

0 comments on commit a8b8ed5

Please sign in to comment.