using storybook
converted to jss
This commit is contained in:
1 parent
6d4fe7749a
commit
df272e138c
33 files changed
+8944
-1650
No files matched your search
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
"stories": [
|
||||
"../src/**/*.stories.mdx",
|
||||
"../src/**/*.stories.@(js|jsx|ts|tsx)"
|
||||
],
|
||||
"addons": [
|
||||
"@storybook/addon-links",
|
||||
"@storybook/addon-essentials"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export const parameters = {
|
||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/,
|
||||
},
|
||||
},
|
||||
}
|
||||
+14
-1
@@ -1,21 +1,32 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"color": "^4.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jss": "^10.8.2",
|
||||
"jss-preset-default": "^10.8.2",
|
||||
"parcel": "^2.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-jss": "^10.8.2",
|
||||
"react-router-dom": "^5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@parcel/transformer-sass": "^2.0.0",
|
||||
"@parcel/transformer-yaml": "^2.0.0",
|
||||
"@storybook/addon-actions": "^6.3.12",
|
||||
"@storybook/addon-essentials": "^6.3.12",
|
||||
"@storybook/addon-links": "^6.3.12",
|
||||
"@storybook/react": "^6.3.12",
|
||||
"@testing-library/jest-dom": "^5.15.0",
|
||||
"@types/color": "^3.0.2",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/js-yaml": "^4.0.4",
|
||||
"@types/node": "^16.11.6",
|
||||
"@types/react": "^17.0.33",
|
||||
"@types/react-dom": "^17.0.10",
|
||||
"@types/react-router-dom": "^5.3.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"babel-plugin-module-resolver": "^4.1.0",
|
||||
"concurrently": "^6.3.0",
|
||||
"husky": "^7.0.4",
|
||||
@@ -38,7 +49,9 @@
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"type-check": "tsc --noEmit",
|
||||
"type-check:watch": "tsc --noEmit --watch"
|
||||
"type-check:watch": "tsc --noEmit --watch",
|
||||
"storybook": "start-storybook -p 6006",
|
||||
"build-storybook": "build-storybook"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
|
||||
@@ -13,8 +13,7 @@ export interface AutomationMetadata {
|
||||
export interface AutomationData {
|
||||
metadata: AutomationMetadata;
|
||||
trigger: AutomationTrigger[];
|
||||
condition: AutomationCondition[];
|
||||
action: AutomationSequenceNode[];
|
||||
sequence: AutomationSequenceNode[];
|
||||
}
|
||||
export type AutomationSequenceNode = AutomationAction | AutomationCondition;
|
||||
type AutomationNodeMapping = {
|
||||
|
||||
@@ -63,6 +63,8 @@ export const getDescriptionFromAutomationNode = <N extends AutomationNodeTypes>(
|
||||
return "Numeric State Condition"
|
||||
case "state":
|
||||
return `${node.condition_data.entity_id} is '${node.condition_data.state}'`
|
||||
case 'template':
|
||||
return node.condition_data.value_template
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { FC } from "react"
|
||||
import { NODE_HEIGHT, NODE_WIDTH } from "./constants"
|
||||
import { Node } from "./types"
|
||||
|
||||
@@ -23,12 +24,39 @@ export default ({
|
||||
<div className="automation-editor--node">
|
||||
<div className={`automation-editor--node-inner top-color ${color}`}>
|
||||
<div className="automation-editor--node-inner-edge left" onClick={onXClick}>
|
||||
<div className="automation-node-side-button">X</div>
|
||||
<span className="automation-node-side-button">X</span>
|
||||
</div>
|
||||
<div className="automation-editor--node-inner-text">
|
||||
<span>{text}</span>
|
||||
</div>
|
||||
<div className="automation-editor--node-inner-text">{text}</div>
|
||||
<div className="automation-editor--node-inner-edge right" onClick={onOpenClick}>
|
||||
<div className="automation-node-side-button">{isOpen ? "▲" : "▼"}</div>
|
||||
<span className="automation-node-side-button">{isOpen ? "▲" : "▼"}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
|
||||
export interface ConditionNodeProps extends NodeProp {
|
||||
conditionType: string;
|
||||
}
|
||||
export const ConditionNode: FC<ConditionNodeProps> = ({
|
||||
loc: [x,y],
|
||||
text,
|
||||
height=NODE_HEIGHT,
|
||||
width=NODE_WIDTH,
|
||||
onXClick=() => {},
|
||||
onOpenClick=() => {},
|
||||
isOpen=false,
|
||||
color,
|
||||
conditionType,
|
||||
children,
|
||||
}) => <foreignObject x={x} y={y} width={width} height={height}>
|
||||
<div className="automation-editor--condition-node">
|
||||
<div className="automation-editor--condition-node-type">
|
||||
{conditionType}
|
||||
</div>
|
||||
<div>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
@@ -6,7 +6,7 @@ import useWindowSize from "~/utils/useWindowSize";
|
||||
import AutoInfoBox from "./AutoInfoBox";
|
||||
import { NODE_HEIGHT, NODE_WIDTH } from "./constants";
|
||||
import DAGEdge from "./DAGEdge";
|
||||
import DAGNode from "./DAGNode";
|
||||
import DAGNode, { ConditionNode } from "./DAGNode";
|
||||
import { Point } from "./types";
|
||||
|
||||
interface Props {
|
||||
@@ -47,8 +47,23 @@ export default function AutomationEditor({
|
||||
lastNodeLoc = [nodeLoc[0] + NODE_WIDTH*((i - 1)*nHDF+1), nodeLoc[1] + NODE_HEIGHT/2];
|
||||
nodeLoc[0] += NODE_WIDTH*i*nHDF
|
||||
}
|
||||
let children = <></>;
|
||||
if (
|
||||
(condition.condition === 'and') ||
|
||||
(condition.condition === 'or') ||
|
||||
(condition.condition === 'not')
|
||||
) {
|
||||
// children = condition.condition_data.conditions.map((c,i) => renderMidCondition(c,i))
|
||||
}
|
||||
return <>
|
||||
<DAGNode key={`node.${i}`} loc={nodeLoc} text={getDescriptionFromAutomationNode(condition)} color="blue"/>
|
||||
<ConditionNode
|
||||
conditionType={condition.condition}
|
||||
key={`node.${i}`}
|
||||
loc={nodeLoc}
|
||||
text={getDescriptionFromAutomationNode(condition)} color="blue"
|
||||
>
|
||||
{children}
|
||||
</ConditionNode>
|
||||
<DAGEdge
|
||||
key={`edge.${i}`}
|
||||
p1={lastNodeLoc}
|
||||
@@ -81,8 +96,8 @@ export default function AutomationEditor({
|
||||
<g className="triggers">
|
||||
{automation.trigger.map(renderTrigger)}
|
||||
</g>
|
||||
<g className="conditions">
|
||||
{automation.condition.map(renderMidCondition)}
|
||||
<g className="sequence">
|
||||
{automation.sequence.map(renderMidCondition)}
|
||||
</g>
|
||||
<circle className="blue" cx={pointTrigToCond[0]} cy={pointTrigToCond[1]} r={2}/>
|
||||
<g className="actions">
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,28 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import { ConditionEditor } from ".";
|
||||
|
||||
export default {
|
||||
title: 'ConditionEditor',
|
||||
component: ConditionEditor,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof ConditionEditor>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof ConditionEditor> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
return <div className={classes.page}>
|
||||
<ConditionEditor {...args} />
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleGraph = Template.bind({})
|
||||
SimpleGraph.args = {
|
||||
condition: {
|
||||
$smType: 'condition',
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: "states('switch.light_kitchen') == 'on'"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationCondition } from "~/automations/types/conditions";
|
||||
import { getDescriptionFromAutomationNode } from "~/automations/utils";
|
||||
import { useStyles } from "./style";
|
||||
|
||||
|
||||
|
||||
export const ConditionEditor: FC<{
|
||||
condition: AutomationCondition;
|
||||
onDelete: (which: 'root' | number) => void;
|
||||
onAddChild: () => void;
|
||||
}> = ({
|
||||
condition,
|
||||
onDelete,
|
||||
// onAddChild,
|
||||
}) => {
|
||||
// alias
|
||||
let children = getDescriptionFromAutomationNode(condition);
|
||||
let hasChildren = false;
|
||||
if (condition.condition === "not") {
|
||||
children = "not"
|
||||
hasChildren = true
|
||||
} else if (condition.condition ==='and') {
|
||||
children = "and"
|
||||
hasChildren = true
|
||||
} else if (condition.condition ==='or') {
|
||||
children = "or"
|
||||
hasChildren = true
|
||||
}
|
||||
|
||||
// styles
|
||||
const {classes} = useStyles({ hasChildren });
|
||||
|
||||
// components
|
||||
const DeleteButton = (p: {onClick?: () => void, isRoot?: boolean}) =>
|
||||
<button className={p.isRoot ? classes.deleteBtnRoot : classes.deleteBtn} onClick={p?.onClick}>X</button>
|
||||
|
||||
return <div className={classes.root}>
|
||||
<DeleteButton isRoot onClick={ () => onDelete('root')}/>
|
||||
<div className={classes.title}>
|
||||
{condition.condition.replace('_', '')}
|
||||
</div>
|
||||
<div className={classes.children}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { Styles } from "jss";
|
||||
import { createAppUseStyles } from "~/styles/theme";
|
||||
|
||||
export const useStyles = createAppUseStyles<{
|
||||
hasChildren: boolean
|
||||
}>(theme => {
|
||||
const deleteBtn: Styles = {
|
||||
borderRadius: '10px',
|
||||
borderStyle: 'none',
|
||||
padding: '0',
|
||||
margin: '0',
|
||||
background: theme.red,
|
||||
width: '30px',
|
||||
height: '15px',
|
||||
fontSize: '10px',
|
||||
textAlign: 'center',
|
||||
cursor: 'pointer',
|
||||
"&:hover": {
|
||||
background: theme.redAccent,
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: ({ hasChildren }) => ({
|
||||
background: theme.primary,
|
||||
padding: 0,
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: hasChildren? 'column' : 'row',
|
||||
width: hasChildren? '100%' : undefined,
|
||||
height: hasChildren? '100%' : undefined,
|
||||
}),
|
||||
title: {
|
||||
background: theme.condition.primaryColor,
|
||||
border: `1px solid ${theme.primaryAccent}`,
|
||||
borderRadius: 10,
|
||||
borderTopRightRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
padding: 10,
|
||||
maxWidth: 80,
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
deleteBtnRoot: {
|
||||
...deleteBtn,
|
||||
position: 'absolute',
|
||||
left: -35,
|
||||
top: 10,
|
||||
},
|
||||
deleteBtn,
|
||||
children: ({}) => ({
|
||||
flex: 1,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
border: `1px solid ${theme.primaryAccent}`,
|
||||
borderRadius: 10,
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import InputText from "./InputText";
|
||||
|
||||
export default {
|
||||
title: 'InputText',
|
||||
component: InputText,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
} as ComponentMeta<typeof InputText>;
|
||||
|
||||
|
||||
const Template: ComponentStory<typeof InputText> = args => {
|
||||
const {classes} = usePageTheme({});
|
||||
const [value, setValue] = useState('')
|
||||
return <div className={classes.page}>
|
||||
<InputText {...args} value={value} onChange={setValue}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
export const SimpleText = Template.bind({})
|
||||
SimpleText.args = {
|
||||
label: "Entity ID",
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useToolTip } from "~/tooltip/context";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
import { useInputTextStyles } from "./styles";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
@@ -15,9 +16,11 @@ export default function InputText({
|
||||
onChange,
|
||||
additionalTooltipFilters={},
|
||||
}: Props) {
|
||||
const {classes} = useInputTextStyles({});
|
||||
const tooltip = useToolTip();
|
||||
return <InputWrapper label={label}>
|
||||
return <InputWrapper label={label} labelSize={value === '' ? 'normal' : 'small'}>
|
||||
<input
|
||||
className={classes.input}
|
||||
value={value}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { CSSProperties, PropsWithChildren } from "react";
|
||||
import { PropsWithChildren } from "react";
|
||||
import { useInputWrapperStyles } from "./styles";
|
||||
|
||||
|
||||
export interface Props {
|
||||
label: string;
|
||||
style?: CSSProperties;
|
||||
labelSize?: 'normal' | 'small';
|
||||
}
|
||||
export default function InputWrapper({label, children, style={}}: PropsWithChildren<Props>) {
|
||||
return <div className="input-wrapper" style={style}>
|
||||
<label>{label}</label>
|
||||
export default function InputWrapper({label, children, labelSize='normal'}: PropsWithChildren<Props>) {
|
||||
const {classes} = useInputWrapperStyles({labelSize})
|
||||
return <div className={classes.wrapper}>
|
||||
<label className={classes.label}>{label}</label>
|
||||
{children}
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Styles } from "jss";
|
||||
import { createAppUseStyles, AppTheme } from "~/styles/theme";
|
||||
|
||||
const commonInputStyle = (theme: AppTheme): Styles => ({
|
||||
input: {
|
||||
backgroundColor: theme.secondary,
|
||||
color: theme.secondaryAccent,
|
||||
borderColor: theme.primaryAccent,
|
||||
borderStyle: 'solid',
|
||||
borderWidth: 1,
|
||||
borderRadius: 5,
|
||||
padding: 10,
|
||||
marginLeft: 5,
|
||||
marginRight: 5,
|
||||
fontSize: 16,
|
||||
|
||||
"&:hover": {
|
||||
backgroundColor: theme.primary,
|
||||
borderColor: theme.secondaryAccent,
|
||||
},
|
||||
"&:disabled": {
|
||||
backgroundColor: '#403f3f',
|
||||
borderColor: '#403f3f',
|
||||
color: '#403f3faa',
|
||||
cursor: 'not-allowed',
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export const useInputWrapperStyles = createAppUseStyles<{
|
||||
labelSize: 'normal' | 'small',
|
||||
}>(theme => {
|
||||
return {
|
||||
wrapper: {
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
marginTop: 10,
|
||||
marginBottom: '0.25em',
|
||||
},
|
||||
label: ({ labelSize }) => ({
|
||||
fontSize: labelSize === 'normal' ? 16 : 10,
|
||||
position: 'absolute',
|
||||
left: labelSize === 'normal' ? '0.75em': '1em',
|
||||
top: labelSize === 'normal' ? '0.5em' : '0.25em',
|
||||
fontWeight: 'bold',
|
||||
transition: 'all 200ms',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export const useInputTextStyles = createAppUseStyles<{}>(theme => ({
|
||||
...commonInputStyle(theme),
|
||||
}));
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="styles/index.scss" />
|
||||
<link rel="stylesheet" href="scss_styles/index.scss" />
|
||||
|
||||
<title>Shortumation</title>
|
||||
</head>
|
||||
|
||||
+39
-38
@@ -1,8 +1,11 @@
|
||||
import { useState } from "react";
|
||||
import { ConditionEditor } from "~/components/ConditionEditor";
|
||||
import { usePageTheme } from "~/styles/page";
|
||||
import { AutomationData } from "../automations/types";
|
||||
import AutomationEditor from "../components/AutomationEditor";
|
||||
|
||||
export function Home() {
|
||||
const {classes} = usePageTheme({});
|
||||
const [automation, setAutomation] = useState<AutomationData>({
|
||||
metadata: {
|
||||
id: "X12314akx",
|
||||
@@ -23,14 +26,7 @@ export function Home() {
|
||||
subtype: "remote_button_double_press"
|
||||
}
|
||||
],
|
||||
condition: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
},
|
||||
sequence: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'and',
|
||||
@@ -43,46 +39,51 @@ export function Home() {
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
action: [
|
||||
{
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
alias: "Start Music In Kitchen",
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "action",
|
||||
action: "service",
|
||||
action_data: {
|
||||
alias: "Start Music In Kitchen",
|
||||
service: 'media_player.play_media',
|
||||
target: {
|
||||
entity_id: "media_player.kitchen_dot"
|
||||
},
|
||||
data: {
|
||||
media_content_id: "Good Morning",
|
||||
media_content_type: "SPOTIFY",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
return (
|
||||
<div id="page--home" className="page">
|
||||
<AutomationEditor
|
||||
<div className={classes.page}>
|
||||
{/* <AutomationEditor
|
||||
automation={automation}
|
||||
onUpdate={setAutomation}
|
||||
/> */}
|
||||
<ConditionEditor
|
||||
onAddChild={() => {}}
|
||||
onDelete={() => {}}
|
||||
condition={{
|
||||
$smType: 'condition',
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: "states(asdacaca) is 'on'"
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/* <div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-around",
|
||||
alignItems: "center",
|
||||
width: "100vw"
|
||||
}}
|
||||
>
|
||||
<AutomationEditor automation={sample}/>
|
||||
</div> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File renamed without changes.
@@ -103,13 +103,11 @@ textarea {
|
||||
@extend button;
|
||||
cursor: text;
|
||||
margin: 0;
|
||||
width: 98%;
|
||||
height: 100%;
|
||||
}
|
||||
span.checkbox {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
border: 1px $primary-accent solid;
|
||||
align-content: center;
|
||||
+5
-18
@@ -1,7 +1,6 @@
|
||||
.automation-editor {
|
||||
height: 99%;
|
||||
width: 99%;
|
||||
font-size: 0.5em;
|
||||
color: $primary-accent;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -25,27 +24,12 @@
|
||||
}
|
||||
|
||||
&-info-box {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
overflow: auto;
|
||||
|
||||
// .input-wrapper {
|
||||
// max-height: 100%;
|
||||
// max-width: 100%;
|
||||
// height: 100%;
|
||||
// width: 100%;
|
||||
|
||||
// * {
|
||||
// margin: 0;
|
||||
// }
|
||||
// input,
|
||||
// textarea,
|
||||
// div {
|
||||
// font-size: 1em;
|
||||
// resize: none;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
.edge {
|
||||
stroke: $secondary-accent;
|
||||
@@ -53,6 +37,9 @@
|
||||
#arrow > path {
|
||||
fill: $secondary-accent;
|
||||
}
|
||||
span {
|
||||
font-size: 8px;
|
||||
}
|
||||
|
||||
&--node {
|
||||
display: flex;
|
||||
+6
-3
@@ -2,19 +2,22 @@
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 0.25em;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 0.25em;
|
||||
|
||||
label {
|
||||
font-size: 0.5em;
|
||||
font-size: 10px;
|
||||
position: absolute;
|
||||
left: 0.75em;
|
||||
top: 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
select,
|
||||
textarea,
|
||||
input {
|
||||
padding-top: 0.65em;
|
||||
padding-top: 16px;
|
||||
padding-left: 8px;
|
||||
resize: none;
|
||||
}
|
||||
// .input-view {
|
||||
// @extend input;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,46 @@
|
||||
import { createAppUseStyles } from "./theme";
|
||||
|
||||
export const usePageTheme = createAppUseStyles(theme => ({
|
||||
page: {
|
||||
// dims
|
||||
height: '100vh',
|
||||
width: '100vw',
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
overflow: 'hidden',
|
||||
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: 'center',
|
||||
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,32 @@
|
||||
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'
|
||||
}));
|
||||
|
||||
type GetThemeType<C extends Context<any>> = C extends Context<infer T> ? T : unknown;
|
||||
export type AppTheme = GetThemeType<typeof ThemeContext>;
|
||||
export const createAppUseStyles = <
|
||||
Props extends {} = {},
|
||||
C extends string = string,
|
||||
>(f: (theme: AppTheme) => Styles<C, Props, AppTheme>) => (props: Props) => {
|
||||
const theme = useTheme();
|
||||
const useStyles = createUseStyles<C,Props,AppTheme>(f)
|
||||
const classes = useStyles({...props, theme});
|
||||
return {classes, theme};
|
||||
}
|
||||
+8503
-1572
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user