Working webapp
This commit is contained in:
1 parent
262e2971a1
commit
75f0841978
11 files changed
+3713
-134
No files matched your search
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
"stories": [
|
||||
"../src/**/*.stories.mdx",
|
||||
"../src/**/*.stories.@(js|jsx|ts|tsx)"
|
||||
],
|
||||
"addons": [
|
||||
"@storybook/addon-links",
|
||||
"@storybook/addon-essentials",
|
||||
"@storybook/preset-create-react-app"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export const parameters = {
|
||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/,
|
||||
},
|
||||
},
|
||||
}
|
||||
+25
-2
@@ -10,9 +10,13 @@
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"chroma-js": "^2.1.2",
|
||||
"jss": "^10.8.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-jss": "^10.8.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"theming": "^3.3.0",
|
||||
"typescript": "^4.1.2",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
@@ -20,12 +24,24 @@
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
"eject": "react-scripts eject",
|
||||
"storybook": "start-storybook -p 6006 -s public",
|
||||
"build-storybook": "build-storybook -s public"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"**/*.stories.*"
|
||||
],
|
||||
"rules": {
|
||||
"import/no-anonymous-default-export": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
@@ -40,5 +56,12 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {}
|
||||
"devDependencies": {
|
||||
"@storybook/addon-actions": "^6.3.12",
|
||||
"@storybook/addon-essentials": "^6.3.12",
|
||||
"@storybook/addon-links": "^6.3.12",
|
||||
"@storybook/node-logger": "^6.3.12",
|
||||
"@storybook/preset-create-react-app": "^3.2.0",
|
||||
"@storybook/react": "^6.3.12"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { createAppUseStyles } from 'styles/theme';
|
||||
import { AnchorHTMLAttributes, FC } from "react";
|
||||
|
||||
|
||||
|
||||
export const useIconStyles = createAppUseStyles<{size: number, color?: string}>(theme => ({
|
||||
icon: ({size}) => ({
|
||||
height: `${size}em`,
|
||||
width: `${size}em`,
|
||||
display: 'flex',
|
||||
}),
|
||||
svg: ({color=theme.primaryAccent}) => ({
|
||||
fill: color
|
||||
})
|
||||
}))
|
||||
|
||||
export type IconBaseProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||
size?: number;
|
||||
color?: string;
|
||||
}
|
||||
export const IconBase: FC<IconBaseProps & { viewBox: string }> = ({
|
||||
children,
|
||||
viewBox,
|
||||
size=1,
|
||||
color,
|
||||
className="",
|
||||
...props
|
||||
}) => {
|
||||
const {classes} = useIconStyles({ size, color });
|
||||
return <a className={`${classes.icon} ${className}`} {...props}>
|
||||
<svg className={classes.svg} version="1.1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox={viewBox}>
|
||||
<g>
|
||||
{children}
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ComponentStory } from "@storybook/react";
|
||||
import { usePageTheme } from "styles/page";
|
||||
import { IconBase } from "./base";
|
||||
import {PencilIcon, CheckMarkIcon} from ".";
|
||||
|
||||
export default {
|
||||
title: 'Icons',
|
||||
component: IconBase,
|
||||
};
|
||||
|
||||
|
||||
export const IconList: ComponentStory<typeof IconBase> = (args) => {
|
||||
const {classes} = usePageTheme({});
|
||||
return <div className={classes.page}>
|
||||
<PencilIcon {...args}/>
|
||||
<CheckMarkIcon {...args}/>
|
||||
</div>
|
||||
}
|
||||
IconList.args = {
|
||||
size: 2,
|
||||
color: 'red'
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { FC } from "react";
|
||||
import { IconBase, IconBaseProps } from "./base";
|
||||
|
||||
|
||||
export const PencilIcon: FC<IconBaseProps> = props => <IconBase {...props} viewBox="0 0 512 512">
|
||||
<path d="M358.752,51.159L70.113,339.798l102.063,102.064L455.088,158.95L512,0.282L358.752,51.159z M172.176,419.287
|
||||
l-79.488-79.489L349.536,82.949l0.069,11.622l22.52-0.089l0.089,22.667l22.625,0.048l-0.048,22.691l22.467-0.271l0.27,22.847
|
||||
l11.538-0.068L172.176,419.287z M442.648,146.351l-9.345,0.055l-0.27-22.946l-22.244,0.269l0.048-22.464l-22.721-0.048
|
||||
l-0.091-22.764l-22.551,0.089l-0.068-11.463l1.963-1.963l75.812-25.169l4.761,23.811l22.704,4.541L442.648,146.351z
|
||||
M461.506,50.195l-3.062-15.313l27.457-9.116l-9.808,27.346L461.506,50.195z"/>
|
||||
|
||||
<rect x="37.686" y="394.032" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -97.0284 763.8365)" width="143.992" height="15.962"/>
|
||||
<path d="M10.388,399.522c-13.851,13.852-13.851,36.391,0,50.244l51.546,51.545c6.711,6.711,15.632,10.406,25.122,10.406
|
||||
s18.412-3.696,25.122-10.406l37.073-37.073L47.462,362.45L10.388,399.522z M100.891,490.025
|
||||
c-3.695,3.696-8.608,5.731-13.834,5.731s-10.139-2.036-13.834-5.731L21.676,438.48c-7.629-7.628-7.629-20.042,0-27.67
|
||||
l25.785-25.785l79.215,79.216L100.891,490.025z"/>
|
||||
</IconBase>;
|
||||
|
||||
export const CheckMarkIcon: FC<IconBaseProps> = props => <IconBase {...props} viewBox="0 0 24 24">
|
||||
<path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/>
|
||||
</IconBase>;
|
||||
@@ -0,0 +1,46 @@
|
||||
import { createAppUseStyles } from "./theme";
|
||||
|
||||
export const usePageTheme = createAppUseStyles(theme => ({
|
||||
page: {
|
||||
// dims
|
||||
height: '100vh',
|
||||
width: '100vw',
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
overflow: 'auto',
|
||||
maxWidth: '100vw',
|
||||
maxHeight: '100vh',
|
||||
|
||||
// font
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Tahoma, Geneva, sans-serif',
|
||||
color: theme.primaryAccent,
|
||||
|
||||
// background
|
||||
backgroundColor: theme.primary,
|
||||
|
||||
// children
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'center',
|
||||
|
||||
'> div': {
|
||||
flex: 1,
|
||||
},
|
||||
|
||||
// scroll
|
||||
'&::-webkit-scrollbar': {
|
||||
width: '10px'
|
||||
},
|
||||
'&::-webkit-scrollbar-track': {
|
||||
background: theme.secondary,
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb': {
|
||||
background: theme.secondaryAccent,
|
||||
},
|
||||
'&::-webkit-scrollbar-thumb:hover': {
|
||||
background: theme.primaryAccent,
|
||||
},
|
||||
}
|
||||
}))
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Classes } from "jss";
|
||||
import { Context, createContext } from "react"
|
||||
import { createUseStyles, Styles } from "react-jss";
|
||||
import { createTheming } from "theming"
|
||||
// import Color from 'color';
|
||||
|
||||
export const {
|
||||
context: ThemeContext,
|
||||
ThemeProvider,
|
||||
useTheme,
|
||||
} = createTheming(createContext({
|
||||
primary: '#111111',
|
||||
secondary: '#1c1c1c',
|
||||
primaryAccent: '#bbbbbb',
|
||||
secondaryAccent: '#929191',
|
||||
condition: {
|
||||
primaryColor: '#4f4f77',
|
||||
},
|
||||
red: '#ed0c0c',
|
||||
redAccent: '#9f3a3a',
|
||||
}));
|
||||
|
||||
export type GetThemeType<C extends Context<any>> = C extends Context<infer T> ? T : unknown;
|
||||
export type ClassNamesOfStyle<F extends Function> = Record<keyof ReturnType<F>, string>;
|
||||
export type AppTheme = GetThemeType<typeof ThemeContext>;
|
||||
export const createAppUseStyles = <
|
||||
Props extends {} = {},
|
||||
C extends string = string,
|
||||
>(f: (theme: AppTheme) => Styles<C, Props, AppTheme>) => (props: Props): {
|
||||
classes: Classes<keyof Styles<C, Props, AppTheme>>,
|
||||
theme: AppTheme,
|
||||
} => {
|
||||
const theme = useTheme();
|
||||
const useStyles = createUseStyles<C,Props,AppTheme>(f)
|
||||
const classes = useStyles({...props, theme}) as Classes<keyof Styles<C, Props, AppTheme>>;
|
||||
return {classes, theme};
|
||||
}
|
||||
+26
-24
@@ -1,26 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"rootDir": ".",
|
||||
"baseUrl": "./src"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
+3479
-106
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user