diff --git a/.eslintrc.json b/.eslintrc.json index abaa8a4..fac420f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,7 @@ "plugins": ["unused-imports", "@typescript-eslint"], "extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"], "parserOptions": { - "project": ["./tsconfig.json", "./tsconfig.test.json"], + "project": ["./tsconfig.json", "./tsconfig.test.json", "./tsconfig.node.json"], "extraFileExtensions": [".json"] }, "rules": { diff --git a/.idea/webResources.xml b/.idea/webResources.xml index 3e8e25f..6f312f6 100644 --- a/.idea/webResources.xml +++ b/.idea/webResources.xml @@ -6,6 +6,7 @@ + diff --git a/.stylelintrc.json b/.stylelintrc.json index caec3ed..970eb20 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -1,4 +1,5 @@ { + "plugins": ["stylelint-use-logical"], "extends": ["stylelint-config-standard", "stylelint-config-idiomatic-order"], "rules": { "selector-pseudo-class-no-unknown": [ @@ -12,6 +13,7 @@ "declaration-block-no-duplicate-properties": true, "no-duplicate-selectors": true, "selector-class-pattern": "^.*|([a-z][a-zA-Z0-9]+)$", - "custom-property-pattern": ".*" + "custom-property-pattern": ".*", + "csstools/use-logical": "always" } } diff --git a/components/home/EntitySpan/EntitySpan.module.css b/components/home/EntitySpan/EntitySpan.module.css index bd9d543..9b8d34d 100644 --- a/components/home/EntitySpan/EntitySpan.module.css +++ b/components/home/EntitySpan/EntitySpan.module.css @@ -1,35 +1,39 @@ .span { - background: lightgray; - font-size: 1em; - border: 1px solid white; - display: inline-block; position: relative; - padding-inline: 0.2em; + display: inline-block; + border: 1px solid var(--md-sys-color-outline); + background: var(--md-sys-color-surface-variant); border-radius: 4px; + color: var(--md-sys-color-on-surface-variant); + font-size: 1em; + padding-inline: 0.2em; } .spanSimple { - padding-inline-start: 0.2em; position: relative; display: inline-block; + padding-inline-start: 0.2em; } .tooltip { - --background: lightsalmon; - --arrow-width: 0.6em; - --arrow-height: 0.4em; - display: none; + --background: var(--md-sys-color-primary-container); + position: absolute; - left: calc(100% + var(--arrow-width)); - top: -5000%; - bottom: -5000%; - margin: auto 0; + z-index: 1; + display: none; width: max-content; height: max-content; - background: var(--background); padding: 0.5em; + margin: auto 0; + background: var(--background); border-radius: 0.7em; - z-index: 1; + box-shadow: 0 0 6px 1px var(--md-sys-color-shadow); + color: var(--md-sys-color-on-primary-container); + inset-block: -5000%; + inset-inline-start: calc(100% + var(--arrow-width)); + + --arrow-width: 0.6em; + --arrow-height: 0.4em; } .span:is(:focus, :hover) > .tooltip { @@ -37,16 +41,15 @@ } .tooltip::before { - content: ""; - border-style: solid; - top: 0; - bottom: 0; - margin: auto 0; + position: absolute; height: max-content; border-width: var(--arrow-height) var(--arrow-width) var(--arrow-height) 0; + border-style: solid; border-color: transparent var(--background) transparent transparent; - position: absolute; - left: calc(var(--arrow-width) * -1 + 1px); + margin: auto 0; + content: ""; + inset-block: 0; + inset-inline-start: calc(var(--arrow-width) * -1 + 1px); } .img { @@ -58,11 +61,11 @@ } .base { - color: darkgreen; + color: var(--md-sys-color-tertiary); } .produced { - color: darkgoldenrod; + color: var(--md-ref-palette-primary70); } .unknown { @@ -89,32 +92,9 @@ .rightClick { height: 1em; - transform: scaleX(-1) translateY(0.1em); + transform: scaleX(-1) translateY(0.1em) !important; } .clickBtn { fill: red; } - -@media (prefers-color-scheme: dark) { - .span { - border-color: #111111; - background-color: #444; - } - - .base { - color: lightgreen; - } - - .produced { - color: lightsalmon; - } - - .unknown { - color: lightgray; - } - - .tooltip { - --background: darkred; - } -} diff --git a/components/home/GroupBox/GroupBox.module.css b/components/home/GroupBox/GroupBox.module.css index da75cdc..2e7e968 100644 --- a/components/home/GroupBox/GroupBox.module.css +++ b/components/home/GroupBox/GroupBox.module.css @@ -1,24 +1,53 @@ .root { position: relative; - border: 2px solid black; padding: 1em 0.5em; + border: 1px solid var(--md-sys-color-outline); + background-color: var(--md-sys-color-surface); + border-radius: 4px; +} + +.heading { + display: inline-block; + margin-block-start: 0; +} + +.heading:not(:focus-visible)::after { + display: inline-block; + width: 1em; + height: 1em; + background-color: var(--md-sys-color-on-background); + content: ""; + mask: url("/factorio/pencil.svg") no-repeat 50% 50%; + opacity: 0.8; + padding-inline-start: 0.5em; } .quit { - --color: darkred; + --color: var(--md-sys-color-error); + position: absolute; - right: 1em; - top: 1em; - border-radius: 999999px; - background: transparent; border: 1px solid var(--color); + background: transparent; + border-radius: 999999px; color: var(--color); - font-weight: 700; + font-weight: 500; + inset-block-start: 1em; + inset-inline-end: 1em; } .quit:is(:focus, :hover) { - --color: red; - filter: drop-shadow(0px 0px 2px rgba(0, 0, 0, 0.5)); + --color: var(--md-ref-palette-error60); + + filter: drop-shadow(0 0 2px var(--md-ref-palette-neutral-variant70)); +} + +.label { + display: block; +} + +.marginTop { + display: block; + margin-block-start: 1em; } .flex { @@ -30,18 +59,3 @@ .flex > * { width: max-content; } - -@media (prefers-color-scheme: dark) { - .root { - border-color: gray; - } - - .quit { - --color: indianred; - } - - .quit:is(:focus, :hover) { - --color: red; - filter: drop-shadow(0px 0px 2px rgba(255, 255, 255, 0.5)); - } -} diff --git a/components/home/GroupBox/GroupBox.tsx b/components/home/GroupBox/GroupBox.tsx index e0e8f6b..9319ce1 100644 --- a/components/home/GroupBox/GroupBox.tsx +++ b/components/home/GroupBox/GroupBox.tsx @@ -5,13 +5,14 @@ import styles from './GroupBox.module.css' import { EntitySpan } from '../EntitySpan/EntitySpan' import { useGroups } from '../../contexts/GroupProvider' import { calculateInputs } from '../../../src/calculateInputs' -import { fixedEncodeURIComponent, uniquify } from '../../../src/utils' -import Link from 'next/link' -import { useRouter } from 'next/router' +import { uniquify } from '../../../src/utils' import { useFactories } from '../../contexts/FactoryProvider' import { i18n, I18n } from '../../shared/I18n/I18n' import { useIntl } from 'react-intl' -import { GraphIcon } from '../../icons/GraphIcon' +import { ButtonVisualize } from '../../shared/ButtonVisualize/ButtonVisualize' +import { Heading } from '../../shared/Heading' +import typography from '../../../styles/typography.module.css' +import cx from 'classnames' interface Props { group: Group @@ -19,7 +20,6 @@ interface Props { const GroupBoxBase: FC = ({ group }) => { const intl = useIntl() - const { query } = useRouter() const { factories, findFactory } = useFactories() const { doNotSuggest, @@ -33,6 +33,7 @@ const GroupBoxBase: FC = ({ group }) => { getInputType } = useGroups() const { name, exports, malls } = group + const nameForId = useMemo(() => name.replace(/[^a-z\d_-]/gi, ''), [name]) const [isDeleteConfirm, setDeleteConfirm] = useState(false) @@ -79,26 +80,30 @@ const GroupBoxBase: FC = ({ group }) => { return (
-

+ { event.currentTarget.innerText = event.currentTarget.innerText.trim() renameGroup(name, event.currentTarget.innerText) }} - > - {name} -

- { + if (event.key === 'Enter') { + event.preventDefault() + event.currentTarget.blur() + } + if (event.key === 'Escape') { + event.preventDefault() + event.currentTarget.innerText = name + event.currentTarget.blur() + } }} > - - - - + {name} + -

- -

- -

- -

- + + {inputs.length ? ( <> -

+ -

+
{inputs.map(input => ( = ({ group }) => { ) : null} {intermediates.length ? ( <> -

+ -

+
{intermediates.map(intermediate => ( = ({ group }) => { ) : null} {suggestionsExport.length ? ( <> -

+ -

+
{suggestionsExport.map(suggestion => ( = ({ group }) => { ) : null} {suggestionMall.length ? ( <> -

+ -

+
{suggestionMall.map(suggestion => ( * { +.entitySpanList > * { width: max-content; } diff --git a/components/home/Home.tsx b/components/home/Home.tsx index d960640..57937e4 100644 --- a/components/home/Home.tsx +++ b/components/home/Home.tsx @@ -1,125 +1,38 @@ -import { ElementRef, FC, useMemo, useRef } from 'react' +import { FC } from 'react' import { GroupBox } from './GroupBox/GroupBox' import styles from './Home.module.css' -import { EnrichedEntity } from '../../src/types' -import { EntitySpan } from './EntitySpan/EntitySpan' import { useGroups } from '../contexts/GroupProvider' -import { Preferences } from './Preferences/Preferences' -import { download, streamToArrayBuffer } from '../../src/download' -import Link from 'next/link' -import { useRouter } from 'next/router' -import { i18n, I18n } from '../shared/I18n/I18n' -import { useFactories } from '../contexts/FactoryProvider' -import { GraphIcon } from '../icons/GraphIcon' -import { useIntl } from 'react-intl' +import { SectionPreferences } from './SectionPreferences/SectionPreferences' +import { I18n } from '../shared/I18n/I18n' +import { Heading } from '../shared/Heading' +import { Paragraph } from '../shared/Paragraph/Paragraph' +import { Section } from '../shared/Section/Section' +import { SectionAddMissing } from './SectionAddMissing/SectionAddMissing' +import { SectionShare } from './SectionShare/SectionShare' +import { ButtonVisualize } from '../shared/ButtonVisualize/ButtonVisualize' export const Home: FC = () => { - const intl = useIntl() - const { query } = useRouter() - const { factories } = useFactories() - const preferencesRef = useRef>(null) - const { groups, doNotSuggest, ignoredFactories, setIgnoredFactories, store, load } = useGroups() - const inputRef = useRef(null) - - const [missingExport, missingMall] = useMemo<[EnrichedEntity[], EnrichedEntity[]]>(() => { - return factories - .filter(factory => !doNotSuggest.has(factory.href) && factory.recipe) - .reduce( - (acc, factory) => - (factory.usedBy?.length ?? 0) >= 3 - ? [[...acc[0], factory], acc[1]] - : [acc[0], [...acc[1], factory]], - [[], []] as [EnrichedEntity[], EnrichedEntity[]] - ) - }, [factories, doNotSuggest]) + const { groups } = useGroups() return (
-

- -

-

- -

- - { - const stream = evt.currentTarget.files?.[0].stream() as - | globalThis.ReadableStream - | undefined - if (stream) { - const array = await streamToArrayBuffer(stream) - load(array) - if (inputRef.current) inputRef.current.value = null as unknown as string - } - }} - /> - - - - - - - -
- - - - - - -
- {missingExport.map(missing => ( - { - preferencesRef.current?.addGroup(missing.name, [missing.href]) - }} - onContextMenu={event => { - event.preventDefault() - setIgnoredFactories([...ignoredFactories, missing.href]) - }} - leftClickText={i18n(intl, 'page.home.tooltip.action.add_to_new_export')} - rightClickText={i18n(intl, 'page.home.tooltip.action.exclude_suggestion')} - /> - ))} -
-
-
- - - - - - -
- {missingMall.map(missing => ( - { - preferencesRef.current?.addGroup(missing.name, undefined, [missing.href]) - }} - onContextMenu={event => { - event.preventDefault() - setIgnoredFactories([...ignoredFactories, missing.href]) - }} - leftClickText={i18n(intl, 'page.home.tooltip.action.add_to_new_mall')} - rightClickText={i18n(intl, 'page.home.tooltip.action.exclude_suggestion')} - /> - ))} -
-
+
+ + + + + + +
+ + + +
+ + + + +
{Object.values(groups) .sort((a, b) => a.name.localeCompare(b.name)) diff --git a/components/home/Preferences/Preferences.tsx b/components/home/Preferences/Preferences.tsx deleted file mode 100644 index e890f01..0000000 --- a/components/home/Preferences/Preferences.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { forwardRef, ForwardRefRenderFunction, useImperativeHandle, useState } from 'react' -import { FactorySelect } from '../FactorySelect/FactorySelect' -import { useGroups } from '../../contexts/GroupProvider' -import { i18n, I18n } from '../../shared/I18n/I18n' -import { useIntl } from 'react-intl' - -interface Handle { - addGroup(preferredName: string, exported?: string[], mall?: string[]): boolean -} - -const PreferencesBase: ForwardRefRenderFunction = (_, forwardedRef) => { - const intl = useIntl() - const DEFAULT_NAME = i18n(intl, 'page.home.group.add.default_group_name') - useImperativeHandle(forwardedRef, () => ({ - addGroup(preferredName: string, exported?: string[], mall?: string[]) { - const name = newGroupValue !== DEFAULT_NAME ? newGroupValue : preferredName - const result = addGroup(name, exported, mall) - result && setNewGroupValue(DEFAULT_NAME) - return result - } - })) - - const { addGroup, baseFactories, setBaseFactories, ignoredFactories, setIgnoredFactories } = - useGroups() - const [newGroupValue, setNewGroupValue] = useState(DEFAULT_NAME) - return ( - <> -
- - - - - - - -
-
- - - - - - - -
-
- - - - setNewGroupValue(e.target.value)} /> - -
- - ) -} - -export const Preferences = forwardRef(PreferencesBase) diff --git a/components/home/Recipe/Recipe.tsx b/components/home/Recipe/Recipe.tsx index a4f4357..a81cfe7 100644 --- a/components/home/Recipe/Recipe.tsx +++ b/components/home/Recipe/Recipe.tsx @@ -2,6 +2,7 @@ import { FC } from 'react' import { Recipe } from '../../../src/types' import { EntityIcon } from '../EntityIcon/EntityIcon' import styles from './Recipe.module.css' +import { I18n } from '../../shared/I18n/I18n' interface Props { recipe: Recipe @@ -23,7 +24,8 @@ export const RecipeSpan: FC = ({ recipe }) => { const after = Object.entries({ ...recipe.output }).map(toEntityIcon) return ( - {joinByPlus([toEntityIcon(['/Time', recipe.time]), ...before])} → {joinByPlus(after)} + {joinByPlus([toEntityIcon(['/Time', recipe.time]), ...before])}{' '} + {joinByPlus(after)} ) } diff --git a/components/home/SectionAddMissing/SectionAddMissing.module.css b/components/home/SectionAddMissing/SectionAddMissing.module.css new file mode 100644 index 0000000..09f0627 --- /dev/null +++ b/components/home/SectionAddMissing/SectionAddMissing.module.css @@ -0,0 +1,9 @@ +.addBtn { + margin-inline: 1em; +} + +.entitySpanList { + display: flex; + flex-wrap: wrap; + gap: 0.1em; +} diff --git a/components/home/SectionAddMissing/SectionAddMissing.tsx b/components/home/SectionAddMissing/SectionAddMissing.tsx new file mode 100644 index 0000000..5dac295 --- /dev/null +++ b/components/home/SectionAddMissing/SectionAddMissing.tsx @@ -0,0 +1,123 @@ +import { FC, useCallback, useMemo, useState } from 'react' +import { Heading } from '../../shared/Heading' +import { i18n, I18n } from '../../shared/I18n/I18n' +import { Paragraph } from '../../shared/Paragraph/Paragraph' +import styles from './SectionAddMissing.module.css' +import { EntitySpan } from '../EntitySpan/EntitySpan' +import { Section } from '../../shared/Section/Section' +import { EnrichedEntity } from '../../../src/types' +import { useFactories } from '../../contexts/FactoryProvider' +import { useGroups } from '../../contexts/GroupProvider' +import { useIntl } from 'react-intl' +import { Input } from '../../shared/Input/Input' +import { Button } from '../../shared/Button/Button' + +export const SectionAddMissing: FC = () => { + const intl = useIntl() + const DEFAULT_NAME = useMemo(() => i18n(intl, 'page.home.group.add.default_group_name'), [intl]) + const { factories } = useFactories() + const { addGroup: addGroupCtx, doNotSuggest, ignoredFactories, setIgnoredFactories } = useGroups() + const [newGroupValue, setNewGroupValue] = useState(DEFAULT_NAME) + const addGroup = useCallback( + (preferredName: string, exported?: string[], mall?: string[]) => { + const name = newGroupValue !== DEFAULT_NAME ? newGroupValue : preferredName + const result = addGroupCtx(name, exported, mall) + result && setNewGroupValue(DEFAULT_NAME) + return result + }, + [DEFAULT_NAME, addGroupCtx, newGroupValue] + ) + + const [missingExport, missingMall] = useMemo<[EnrichedEntity[], EnrichedEntity[]]>(() => { + return factories + .filter(factory => !doNotSuggest.has(factory.href) && factory.recipe) + .reduce( + (acc, factory) => + (factory.usedBy?.length ?? 0) >= 3 + ? [[...acc[0], factory], acc[1]] + : [acc[0], [...acc[1], factory]], + [[], []] as [EnrichedEntity[], EnrichedEntity[]] + ) + }, [factories, doNotSuggest]) + + return ( +
+ + + + setNewGroupValue(e.target.value)} /> + + + + + + + + {missingExport.length ? ( +
+ {missingExport.map(missing => ( + { + addGroup(missing.name, [missing.href]) + }} + onContextMenu={event => { + event.preventDefault() + setIgnoredFactories([...ignoredFactories, missing.href]) + }} + leftClickText={i18n(intl, 'page.home.tooltip.action.add_to_new_export')} + rightClickText={i18n(intl, 'page.home.tooltip.action.exclude_suggestion')} + /> + ))} +
+ ) : ( + + + + + + )} + + + + + + + {missingMall.length ? ( +
+ {missingMall.map(missing => ( + { + addGroup(missing.name, undefined, [missing.href]) + }} + onContextMenu={event => { + event.preventDefault() + setIgnoredFactories([...ignoredFactories, missing.href]) + }} + leftClickText={i18n(intl, 'page.home.tooltip.action.add_to_new_mall')} + rightClickText={i18n(intl, 'page.home.tooltip.action.exclude_suggestion')} + /> + ))} +
+ ) : ( + + + + + + )} +
+ ) +} diff --git a/components/home/SectionPreferences/SectionPreferences.module.css b/components/home/SectionPreferences/SectionPreferences.module.css new file mode 100644 index 0000000..cca1c29 --- /dev/null +++ b/components/home/SectionPreferences/SectionPreferences.module.css @@ -0,0 +1,3 @@ +.margin-top { + margin-block-start: 2em; +} diff --git a/components/home/SectionPreferences/SectionPreferences.tsx b/components/home/SectionPreferences/SectionPreferences.tsx new file mode 100644 index 0000000..ce91b85 --- /dev/null +++ b/components/home/SectionPreferences/SectionPreferences.tsx @@ -0,0 +1,45 @@ +import { FC } from 'react' +import { FactorySelect } from '../FactorySelect/FactorySelect' +import { useGroups } from '../../contexts/GroupProvider' +import { I18n } from '../../shared/I18n/I18n' +import { Section } from '../../shared/Section/Section' +import { Heading } from '../../shared/Heading' +import { Paragraph } from '../../shared/Paragraph/Paragraph' +import { Collapsible } from '../../shared/Collapsible/Collapsible' +import styles from './SectionPreferences.module.css' + +export const SectionPreferences: FC = () => { + const { baseFactories, setBaseFactories, ignoredFactories, setIgnoredFactories } = useGroups() + return ( +
+ + + + + + + + + + + + + + + + + + + +
+ ) +} diff --git a/components/home/SectionShare/SectionShare.module.css b/components/home/SectionShare/SectionShare.module.css new file mode 100644 index 0000000..04ab8a2 --- /dev/null +++ b/components/home/SectionShare/SectionShare.module.css @@ -0,0 +1,30 @@ +.shareGrid { + display: grid; + gap: 3em; + grid-template-columns: repeat(auto-fit, minmax(30ch, 1fr)); +} + +.downloadBtn { + width: 100%; +} + +.uploadInput { + display: inline-block; + width: 100%; + padding: 2em 0.5em; + border: 1px dashed var(--md-sys-color-on-secondary-container); + margin: 1em 0; + background-color: var(--md-sys-color-secondary-container); + border-radius: 4px; + color: var(--md-sys-color-on-secondary-container); + text-align: center; +} + +.shareInput { + width: 100%; +} + +.uploadInput > input { + width: 0; + visibility: hidden; +} diff --git a/components/home/SectionShare/SectionShare.tsx b/components/home/SectionShare/SectionShare.tsx new file mode 100644 index 0000000..5e7a189 --- /dev/null +++ b/components/home/SectionShare/SectionShare.tsx @@ -0,0 +1,80 @@ +import { FC, useEffect, useState } from 'react' +import styles from './SectionShare.module.css' +import { Heading } from '../../shared/Heading' +import { Paragraph } from '../../shared/Paragraph/Paragraph' +import { Button } from '../../shared/Button/Button' +import cx from 'classnames' +import typography from '../../../styles/typography.module.css' +import { download, streamToArrayBuffer } from '../../../src/download' +import { I18n } from '../../shared/I18n/I18n' +import { Input } from '../../shared/Input/Input' +import { Section } from '../../shared/Section/Section' +import { useGroups } from '../../contexts/GroupProvider' + +export const SectionShare: FC = () => { + const { store, load } = useGroups() + + const [location, setLocation] = useState('') + useEffect(() => { + setLocation(window.location.href) + }, []) + + return ( +
+
+
+ + + + + + + + +
+
+ + + + + + + + + + + + e.currentTarget.select()} + /> +
+
+
+ ) +} diff --git a/components/icons/Icon.module.css b/components/icons/Icon.module.css index c674e38..39ab1b0 100644 --- a/components/icons/Icon.module.css +++ b/components/icons/Icon.module.css @@ -1,11 +1,7 @@ .icon { height: 1em; + fill: currentcolor; padding-inline: 0.5ch; + stroke: currentcolor; transform: translateY(0.1em); } - -@media (prefers-color-scheme: dark) { - .icon { - filter: invert(100%); - } -} diff --git a/components/shared/Button/Button.module.css b/components/shared/Button/Button.module.css new file mode 100644 index 0000000..00d03ee --- /dev/null +++ b/components/shared/Button/Button.module.css @@ -0,0 +1,13 @@ +.root { + padding: 1em; + border: 0; + background-color: var(--md-sys-color-secondary); + border-radius: 4px; + color: var(--md-sys-color-on-secondary); + transition: box-shadow 0.075s linear; +} + +.root:hover, +.root:focus-visible { + box-shadow: 2px 2px 5px 1px rgba(0 0 0 / 50%); +} diff --git a/components/shared/Button/Button.tsx b/components/shared/Button/Button.tsx new file mode 100644 index 0000000..b84540e --- /dev/null +++ b/components/shared/Button/Button.tsx @@ -0,0 +1,13 @@ +import { ButtonHTMLAttributes, FC } from 'react' +import cx from 'classnames' +import styles from './Button.module.css' + +type Props = ButtonHTMLAttributes + +export const Button: FC = ({ className, children, ...rest }) => { + return ( + + ) +} diff --git a/components/shared/ButtonVisualize/ButtonVisualize.module.css b/components/shared/ButtonVisualize/ButtonVisualize.module.css new file mode 100644 index 0000000..298488c --- /dev/null +++ b/components/shared/ButtonVisualize/ButtonVisualize.module.css @@ -0,0 +1,15 @@ +.root { + display: inline-block; + margin-block-start: -0.4em; + padding-inline: 0.5em; + vertical-align: middle; +} + +.link { + display: inline; + padding: 0.2em; + border-radius: 4px; + box-shadow: 0 0 0 1px var(--md-sys-color-tertiary); + color: var(--md-sys-color-tertiary); + font-size: var(--md-sys-typescale-body-small-font-size); +} diff --git a/components/shared/ButtonVisualize/ButtonVisualize.tsx b/components/shared/ButtonVisualize/ButtonVisualize.tsx new file mode 100644 index 0000000..d108538 --- /dev/null +++ b/components/shared/ButtonVisualize/ButtonVisualize.tsx @@ -0,0 +1,25 @@ +import { FC } from 'react' +import { I18n } from '../I18n/I18n' +import { GraphIcon } from '../../icons/GraphIcon' +import Link from 'next/link' +import { useRouter } from 'next/router' +import styles from './ButtonVisualize.module.css' + +interface Props { + groupId?: string + large?: true +} + +export const ButtonVisualize: FC = ({ groupId, large }) => { + const { query } = useRouter() + return ( + + + + {large ? : null} + + + + + ) +} diff --git a/components/shared/Collapsible/Collapsible.module.css b/components/shared/Collapsible/Collapsible.module.css new file mode 100644 index 0000000..4fa6c5d --- /dev/null +++ b/components/shared/Collapsible/Collapsible.module.css @@ -0,0 +1,58 @@ +.collapsible { + position: relative; +} + +.toggle { + display: none; +} + +.label { + position: absolute; + z-index: 100; + inset-block-start: 0; + inset-inline-end: 0; +} + +.label::before { + display: block; + width: 1em; + height: 1em; + border: 1px solid var(--md-ref-palette-neutral-variant80); + border-radius: 4px; + content: "-"; + font-size: 0.5em; + line-height: 1em; + margin-block-start: 0.5em; + text-align: center; +} + +.content { + position: relative; + overflow: hidden; + max-height: 100vh; + transition: max-height 0.25s ease-in; +} + +.content::after { + position: absolute; + height: 3em; + background: linear-gradient(to bottom, rgba(0 0 0 / 0%) 0%, var(--color-bg) 100%); + content: ""; + inset-block-end: 0; + inset-inline: 0; + pointer-events: none; + transition: height 0.25s ease-in-out; +} + +.toggle:checked + .label::before { + content: "+"; +} + +.toggle:not(:checked) + .label + .content::after { + height: 0; +} + +.toggle:checked + .label + .content { + max-height: 5em; + transition: max-height 0.25s ease-out; +} diff --git a/components/shared/Collapsible/Collapsible.tsx b/components/shared/Collapsible/Collapsible.tsx new file mode 100644 index 0000000..8c1cf32 --- /dev/null +++ b/components/shared/Collapsible/Collapsible.tsx @@ -0,0 +1,25 @@ +import { FC, PropsWithChildren } from 'react' +import styles from './Collapsible.module.css' +import cx from 'classnames' +import typography from '../../../styles/typography.module.css' + +interface Props { + id: string + className?: string +} + +export const Collapsible: FC> = ({ id, className, children }) => { + return ( +
+ + {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} +
+ ) +} diff --git a/components/shared/Heading.tsx b/components/shared/Heading.tsx new file mode 100644 index 0000000..7aeae2a --- /dev/null +++ b/components/shared/Heading.tsx @@ -0,0 +1,35 @@ +import { createElement, FC, HTMLAttributes, PropsWithChildren } from 'react' +import cx from 'classnames' +import typography from '../../styles/typography.module.css' + +interface Props extends HTMLAttributes { + tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span' + type: 'pageTitle' | 'section' | 'subsection' + className?: string +} + +export const Heading: FC> = ({ + tag, + type, + className, + children, + ...rest +}) => { + const TAG: Record> = { + pageTitle: 'h1', + section: 'h2', + subsection: 'h3' + } + return createElement( + tag ?? TAG[type], + { + className: cx(className, { + [typography.displayLarge]: type === 'pageTitle', + [typography.headlineMedium]: type === 'section', + [typography.titleLarge]: type === 'subsection' + }), + ...rest + }, + children + ) +} diff --git a/components/shared/Input/Input.module.css b/components/shared/Input/Input.module.css new file mode 100644 index 0000000..377da43 --- /dev/null +++ b/components/shared/Input/Input.module.css @@ -0,0 +1,8 @@ +.root { + padding: 1em 0.5em; + border: 1px solid var(--color-text, var(--md-sys-color-on-background)); + margin: 0 0 1em; + background-color: var(--color-bg, var(--md-sys-color-background)); + border-radius: 4px; + font-size: var(--md-sys-typescale-body-small-font-size); +} diff --git a/components/shared/Input/Input.tsx b/components/shared/Input/Input.tsx new file mode 100644 index 0000000..4f4e682 --- /dev/null +++ b/components/shared/Input/Input.tsx @@ -0,0 +1,9 @@ +import { FC, InputHTMLAttributes } from 'react' +import styles from './Input.module.css' +import cx from 'classnames' + +type Props = InputHTMLAttributes + +export const Input: FC = ({ className, ...rest }) => { + return +} diff --git a/components/shared/Paragraph/Paragraph.module.css b/components/shared/Paragraph/Paragraph.module.css new file mode 100644 index 0000000..41b4e6a --- /dev/null +++ b/components/shared/Paragraph/Paragraph.module.css @@ -0,0 +1,3 @@ +.subtitle { + margin-block-start: -2em; +} diff --git a/components/shared/Paragraph/Paragraph.tsx b/components/shared/Paragraph/Paragraph.tsx new file mode 100644 index 0000000..5afaca2 --- /dev/null +++ b/components/shared/Paragraph/Paragraph.tsx @@ -0,0 +1,23 @@ +import { FC, PropsWithChildren } from 'react' +import cx from 'classnames' +import typography from '../../../styles/typography.module.css' +import styles from './Paragraph.module.css' + +interface Props { + size: 'large' | 'medium' | 'small' | 'subtitle' +} + +export const Paragraph: FC> = ({ size, children }) => { + return ( +

+ {children} +

+ ) +} diff --git a/components/shared/Section/Section.module.css b/components/shared/Section/Section.module.css new file mode 100644 index 0000000..b99aa76 --- /dev/null +++ b/components/shared/Section/Section.module.css @@ -0,0 +1,33 @@ +.content { + max-width: 80ch; + margin: 0 auto; + padding-block: 2em; + text-align: justify; + + --color-bg: var(--md-sys-color-background); + --color-text: var(--md-sys-color-on-background); +} + +.primary { + --color-bg: var(--md-sys-color-primary-container); + --color-text: var(--md-sys-color-on-primary-container); +} + +.secondary { + --color-bg: var(--md-sys-color-secondary-container); + --color-text: var(--md-sys-color-on-secondary-container); +} + +.tertiary { + --color-bg: var(--md-sys-color-tertiary-container); + --color-text: var(--md-sys-color-on-tertiary-container); +} + +.primary, +.secondary, +.tertiary { + background-color: var(--color-bg); + box-shadow: 0 0 0 100vmax var(--color-bg); + clip-path: inset(0 -100vmax); + color: var(--color-text); +} diff --git a/components/shared/Section/Section.tsx b/components/shared/Section/Section.tsx new file mode 100644 index 0000000..d0a5db9 --- /dev/null +++ b/components/shared/Section/Section.tsx @@ -0,0 +1,26 @@ +import { createContext, FC, PropsWithChildren, useContext } from 'react' +import styles from './Section.module.css' +import cx from 'classnames' + +type SectionContextType = 'primary' | 'secondary' | 'tertiary' | undefined + +interface Props { + color?: SectionContextType +} + +const SectionContext = createContext(undefined) +export const useSectionColor = () => useContext(SectionContext) + +export const Section: FC> = ({ color, children }) => { + return ( +
+ {children} +
+ ) +} diff --git a/components/visualize/NodeOverview/NodeOverview.tsx b/components/visualize/NodeOverview/NodeOverview.tsx index f02a834..429b569 100644 --- a/components/visualize/NodeOverview/NodeOverview.tsx +++ b/components/visualize/NodeOverview/NodeOverview.tsx @@ -43,7 +43,7 @@ export const NodeOverview: FC = ({ node, className, ...props }) => {
) : null}

- +

{node.inputs.map(input => ( @@ -53,7 +53,7 @@ export const NodeOverview: FC = ({ node, className, ...props }) => { {node.outputs.length ? ( <>

- +

{node.outputs.map(input => ( diff --git a/components/visualize/PageDetails.tsx b/components/visualize/PageDetails.tsx index 7fbb623..2cbb0cf 100644 --- a/components/visualize/PageDetails.tsx +++ b/components/visualize/PageDetails.tsx @@ -9,8 +9,11 @@ import Head from 'next/head' import { ScrollContainer } from './ScrollContainer/ScrollContainer' import { ProducingGraph } from './ProducingGraph/ProducingGraph' import { useFactories } from '../contexts/FactoryProvider' +import { i18n, I18n } from '../shared/I18n/I18n' +import { useIntl } from 'react-intl' export const PageDetails: FC = () => { + const intl = useIntl() const { query: { name } } = useRouter() @@ -61,12 +64,16 @@ export const PageDetails: FC = () => { return ( <> - Factorio Microservices - + + <I18n id={'page.visualize.details.title'} values={{ name: group?.name ?? '' }} /> + +
-

{name}

+

+ +

{ + const intl = useIntl() const { exportedFactories, baseFactories, groups } = useGroups() const { findFactory } = useFactories() @@ -28,12 +31,16 @@ export const PageOverview: FC = () => { return ( <> - Factorio Microservices - + + <I18n id={'page.visualize.details.title'} /> + +
-

Factorio Microservices

+

+ +

{ + config.module?.rules?.forEach(rule => { + rule.oneOf?.forEach(oneOf => { + const loader = oneOf?.use + if (!loader || !Array.isArray(loader)) return + loader.forEach(l => { + if (l.loader?.includes('/css-loader') && l.options.modules) { + // mde-ui needs camelCase as well as BEM, so preserve both + l.options.modules.exportLocalsConvention = 'camelCase' + } + }) + }) + }) + + return config } } diff --git a/package.json b/package.json index e023c1a..2bc15a1 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "stylelint": "^14.10.0", "stylelint-config-idiomatic-order": "^8.1.0", "stylelint-config-standard": "^27.0.0", + "stylelint-use-logical": "^2.0.0", "ts-node": "^10.9.1", "typescript": "4.7.4" } diff --git a/pages/_app.tsx b/pages/_app.tsx index 309d87f..07165b7 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,3 +1,6 @@ +import '../styles/font-faces.css' +import '../styles/tokens.css' +import '../styles/theme.css' import '../styles/globals.css' import type { AppProps } from 'next/app' import { FC } from 'react' diff --git a/public/fonts/LICENSE.txt b/public/fonts/LICENSE.txt new file mode 100644 index 0000000..75b5248 --- /dev/null +++ b/public/fonts/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/public/fonts/Roboto-Italic.ttf b/public/fonts/Roboto-Italic.ttf new file mode 100644 index 0000000..1b5eaa3 Binary files /dev/null and b/public/fonts/Roboto-Italic.ttf differ diff --git a/public/fonts/Roboto-Medium.ttf b/public/fonts/Roboto-Medium.ttf new file mode 100644 index 0000000..ac0f908 Binary files /dev/null and b/public/fonts/Roboto-Medium.ttf differ diff --git a/public/fonts/Roboto-MediumItalic.ttf b/public/fonts/Roboto-MediumItalic.ttf new file mode 100644 index 0000000..fc36a47 Binary files /dev/null and b/public/fonts/Roboto-MediumItalic.ttf differ diff --git a/public/fonts/Roboto-Regular.ttf b/public/fonts/Roboto-Regular.ttf new file mode 100644 index 0000000..ddf4bfa Binary files /dev/null and b/public/fonts/Roboto-Regular.ttf differ diff --git a/public/pencil.svg b/public/pencil.svg new file mode 100644 index 0000000..4332e2a --- /dev/null +++ b/public/pencil.svg @@ -0,0 +1 @@ + diff --git a/res/i18n/de.json b/res/i18n/de.json index 64246e1..355ab8b 100644 --- a/res/i18n/de.json +++ b/res/i18n/de.json @@ -9,6 +9,13 @@ "page.home.pref.basic.description": "Grundlegende Waren können nicht in Fabriken hergestellt werden. Es kann sinnvoll sein hier z.B. Eisenplatten hinzuzufügen, wenn jene direkt beim Erz hergestellt werden.", "page.home.pref.ignored.title": "Ignorierte Waren", "page.home.pref.ignored.description": "Waren, die im Einkaufszentrum hergestellt werden sollen (z.B. Befeuerter Greifarm, weil es nicht benötigt wird) und auch nicht zwischen den Mikroservices exportiert werden sollen (z.B. Zahnräder, weil die bei Bedarf in der Fabrik selbst als Zwischenprodukt hergestellt wird).", + "page.home.share.download.title": "Download & Upload", + "page.home.share.download.description": "Lade hier deine Daten herunter, um sie für einen späteren Upload zu speichern. Alle auf dieser Seite vorgenommenen Änderungen werden automatisch gespeichert und können nicht rückgängig gemacht werden. Am besten lädst du daher die Daten daher herunter bevor du etwas ausprobierst.", + "page.home.share.download.upload_text": "Klicke zum Hochladen oder ziehe einen Speicherstand in diesen Bereich!", + "page.home.share.link.title": "Teile und Herrsche!", + "page.home.share.link.description": "Du kannst auch mit deinen Freunden zusammenarbeiten! Teile einfach den folgenden Link!", + "page.home.share.link.warning": "Warnung: Jeder mit diesem Link kann bearbeiten!", + "page.home.group.title": "Gruppen von Microservices", "page.home.group.add.title": "Neue Gruppe hinzufügen", "page.home.group.add.default_group_name": "Neue Gruppe", "page.home.group.add.button_text": "Gruppe \"{name}\" hinzufügen", @@ -32,6 +39,9 @@ "page.home.tooltip.action.add_to_new_export": "Erstelle eine neue Gruppe mit diesem Namen und gut als exportierte Fabrik", "page.home.tooltip.action.add_to_export": "Ware zu exportierten Fabriken hinzufügen", "page.home.tooltip.action.add_to_mall": "Ware als Einkaufszentrum hinzufügen", - "page.visualize.imports": "Importe", - "page.visualize.exports": "Exporte" + "page.visualize.overview.imports": "Importe", + "page.visualize.overview.exports": "Exporte", + "page.visualize.overview.title": "Zusammenhänge der Services", + "page.visualize.details.title": "Group \"{name}\"", + "component.recipe.arrow": "→" } diff --git a/res/i18n/en.json b/res/i18n/en.json index 3998910..8a71bac 100644 --- a/res/i18n/en.json +++ b/res/i18n/en.json @@ -9,6 +9,13 @@ "page.home.pref.basic.description": "Basic goods cannot be produced in factories. It may make sense to add iron plates here, for example, if they are produced directly at the ore.", "page.home.pref.ignored.title": "Ignored goods", "page.home.pref.ignored.description": "Goods that are to be manufactured in in the mall (e.g., burner inserter because it is not needed) and also are not to be exported between microservices (e.g., gears because that is manufactured in the factory itself as an intermediate product when needed).", + "page.home.share.download.title": "Download & Upload", + "page.home.share.download.description": "Download your data here to store it for later upload. All changes made on this page are automatically saved and cannot be undone. So it is recommended to store a stable state before testing something out.", + "page.home.share.download.upload_text": "Click to upload or drop save in this area!", + "page.home.share.link.title": "Divide and Conquer!", + "page.home.share.link.description": "You can also work together with your friends! Just share the following link!", + "page.home.share.link.warning": "Warning: Everyone with this link can edit!", + "page.home.group.title": "Groups of Microservices", "page.home.group.add.title": "Add a new group", "page.home.group.add.default_group_name": "New Group", "page.home.group.add.button_text": "Add group \"{name}\"", @@ -32,6 +39,9 @@ "page.home.tooltip.action.add_to_new_export": "Create a new group with this name and good as exported factory", "page.home.tooltip.action.add_to_export": "Add good to exported factories", "page.home.tooltip.action.add_to_mall": "Add good to mall factories", - "page.visualize.imports": "Imports", - "page.visualize.exports": "Exports" + "page.visualize.overview.imports": "Imports", + "page.visualize.overview.exports": "Exports", + "page.visualize.overview.title": "Interrelationships of Groups", + "page.visualize.details.title": "Group \"{name}\"", + "component.recipe.arrow": "→" } diff --git a/res/i18n/nl.json b/res/i18n/nl.json index 8ad9186..9d4b70e 100644 --- a/res/i18n/nl.json +++ b/res/i18n/nl.json @@ -9,9 +9,16 @@ "page.home.pref.basic.description": "Basisgoederen kunnen niet in fabrieken worden geproduceerd. Het kan zinvol zijn om hier bijvoorbeeld ijzeren platen toe te voegen, als ze direct aan het erts worden geproduceerd.", "page.home.pref.ignored.title": "Genegeerde goederen", "page.home.pref.ignored.description": "Goederen die in in het winkelcentrum moeten worden gefabriceerd (bijv. branderinserter omdat die niet nodig is) en ook niet tussen microservices moeten worden geëxporteerd (bijv. tandwielen omdat dat in de fabriek zelf als tussenproduct wordt gefabriceerd als dat nodig is).", + "page.home.share.download.title": "Downloaden & uploaden", + "page.home.share.download.description": "Download hier je gegevens om ze op te slaan en later te uploaden. Alle wijzigingen op deze pagina worden automatisch opgeslagen en kunnen niet ongedaan worden gemaakt. Het is daarom het beste om de gegevens te downloaden voordat je iets uitprobeert.", + "page.home.share.download.upload_text": "Klik om een opgeslagen bestand te uploaden of te slepen naar dit gebied!", + "page.home.share.link.title": "Verdeel en heers!", + "page.home.share.link.description": "Je kunt ook samenwerken met je vrienden! Deel gewoon de volgende link!", + "page.home.share.link.warning": "Waarschuwing: iedereen met deze link kan bewerken!", + "page.home.group.title": "Microservices groepen", "page.home.group.add.title": "Voeg een nieuwe groep toe", "page.home.group.add.default_group_name": "Nieuwe groep", - "page.home.group.add.button_text": "Groep toevoegen {naam}", + "page.home.group.add.button_text": "Groep \"{name}\" toevoegen", "page.home.group.missing.export.title": "Ontbrekende export fabrieken", "page.home.group.missing.export.description": "Een lijst van alle goederen die geen basisgoederen of genegeerde goederen zijn, en die nog bij geen enkele groep worden geëxporteerd of als winkelcentrumfabriek zijn toegevoegd. Alleen in deze lijst indien gebruikt door ten minste 3 andere goederen.", "page.home.group.missing.mall.title": "Ontbrekende winkelcentrumfabrieken", @@ -19,8 +26,8 @@ "page.home.group.missing.none": "Alle fabrieken toegevoegd!", "page.home.group.item.export": "Uitgevoerde goederen", "page.home.group.item.mall": "Winkelcentrum goederen", - "page.home.group.item.input": "Ingevoerde goederen ({bedrag})", - "page.home.group.item.intermediate": "Tussenliggende fabrieken ({bedrag})", + "page.home.group.item.input": "Ingevoerde goederen ({amount})", + "page.home.group.item.intermediate": "Tussenliggende fabrieken ({amount})", "page.home.group.item.suggestion.export": "Voorgestelde exportgoederen", "page.home.group.item.suggestion.mall": "Voorgestelde winkelcentrum goederen", "page.home.group.delete.confirmation": "Groep permanent verwijderen?", @@ -32,6 +39,9 @@ "page.home.tooltip.action.add_to_new_export": "Maak een nieuwe groep met deze naam en goed als geëxporteerde fabriek", "page.home.tooltip.action.add_to_export": "Voeg goed toe aan geëxporteerde fabrieken", "page.home.tooltip.action.add_to_mall": "Goed toevoegen aan fabrieken in winkelcentrum", - "page.visualize.imports": "Invoer", - "page.visualize.exports": "Uitvoer" + "page.visualize.overview.imports": "Invoer", + "page.visualize.overview.exports": "Uitvoer", + "page.visualize.overview.title": "Microservice Relaties", + "page.visualize.details.title": "Groep \"{name}\"", + "component.recipe.arrow": "→" } diff --git a/styles/colors.module.css b/styles/colors.module.css new file mode 100644 index 0000000..4d372af --- /dev/null +++ b/styles/colors.module.css @@ -0,0 +1,231 @@ +.primary { + background-color: var(--md-sys-color-primary); +} + +.primary-text { + color: var(--md-sys-color-primary); +} + +.on-primary { + background-color: var(--md-sys-color-on-primary); +} + +.on-primary-text { + color: var(--md-sys-color-on-primary); +} + +.primary-container { + background-color: var(--md-sys-color-primary-container); +} + +.primary-container-text { + color: var(--md-sys-color-primary-container); +} + +.on-primary-container { + background-color: var(--md-sys-color-on-primary-container); +} + +.on-primary-container-text { + color: var(--md-sys-color-on-primary-container); +} + +.secondary { + background-color: var(--md-sys-color-secondary); +} + +.secondary-text { + color: var(--md-sys-color-secondary); +} + +.on-secondary { + background-color: var(--md-sys-color-on-secondary); +} + +.on-secondary-text { + color: var(--md-sys-color-on-secondary); +} + +.secondary-container { + background-color: var(--md-sys-color-secondary-container); +} + +.secondary-container-text { + color: var(--md-sys-color-secondary-container); +} + +.on-secondary-container { + background-color: var(--md-sys-color-on-secondary-container); +} + +.on-secondary-container-text { + color: var(--md-sys-color-on-secondary-container); +} + +.tertiary { + background-color: var(--md-sys-color-tertiary); +} + +.tertiary-text { + color: var(--md-sys-color-tertiary); +} + +.on-tertiary { + background-color: var(--md-sys-color-on-tertiary); +} + +.on-tertiary-text { + color: var(--md-sys-color-on-tertiary); +} + +.tertiary-container { + background-color: var(--md-sys-color-tertiary-container); +} + +.tertiary-container-text { + color: var(--md-sys-color-tertiary-container); +} + +.on-tertiary-container { + background-color: var(--md-sys-color-on-tertiary-container); +} + +.on-tertiary-container-text { + color: var(--md-sys-color-on-tertiary-container); +} + +.error { + background-color: var(--md-sys-color-error); +} + +.error-text { + color: var(--md-sys-color-error); +} + +.error-container { + background-color: var(--md-sys-color-error-container); +} + +.error-container-text { + color: var(--md-sys-color-error-container); +} + +.on-error { + background-color: var(--md-sys-color-on-error); +} + +.on-error-text { + color: var(--md-sys-color-on-error); +} + +.on-error-container { + background-color: var(--md-sys-color-on-error-container); +} + +.on-error-container-text { + color: var(--md-sys-color-on-error-container); +} + +.background { + background-color: var(--md-sys-color-background); +} + +.background-text { + color: var(--md-sys-color-background); +} + +.on-background { + background-color: var(--md-sys-color-on-background); +} + +.on-background-text { + color: var(--md-sys-color-on-background); +} + +.surface { + background-color: var(--md-sys-color-surface); +} + +.surface-text { + color: var(--md-sys-color-surface); +} + +.on-surface { + background-color: var(--md-sys-color-on-surface); +} + +.on-surface-text { + color: var(--md-sys-color-on-surface); +} + +.surface-variant { + background-color: var(--md-sys-color-surface-variant); +} + +.surface-variant-text { + color: var(--md-sys-color-surface-variant); +} + +.on-surface-variant { + background-color: var(--md-sys-color-on-surface-variant); +} + +.on-surface-variant-text { + color: var(--md-sys-color-on-surface-variant); +} + +.outline { + background-color: var(--md-sys-color-outline); +} + +.outline-text { + color: var(--md-sys-color-outline); +} + +.inverse-on-surface { + background-color: var(--md-sys-color-inverse-on-surface); +} + +.inverse-on-surface-text { + color: var(--md-sys-color-inverse-on-surface); +} + +.inverse-surface { + background-color: var(--md-sys-color-inverse-surface); +} + +.inverse-surface-text { + color: var(--md-sys-color-inverse-surface); +} + +.inverse-primary { + background-color: var(--md-sys-color-inverse-primary); +} + +.inverse-primary-text { + color: var(--md-sys-color-inverse-primary); +} + +.shadow { + background-color: var(--md-sys-color-shadow); +} + +.shadow-text { + color: var(--md-sys-color-shadow); +} + +.surface-tint { + background-color: var(--md-sys-color-surface-tint); +} + +.surface-tint-text { + color: var(--md-sys-color-surface-tint); +} + +.surface-tint-color { + background-color: var(--md-sys-color-surface-tint-color); +} + +.surface-tint-color-text { + color: var(--md-sys-color-surface-tint-color); +} diff --git a/styles/font-faces.css b/styles/font-faces.css new file mode 100644 index 0000000..0fb0e87 --- /dev/null +++ b/styles/font-faces.css @@ -0,0 +1,31 @@ +@font-face { + font-display: swap; + font-family: Roboto; + font-style: normal; + font-weight: 400; + src: url("/factorio/fonts/Roboto-Regular.ttf") format("woff2"); +} + +@font-face { + font-display: swap; + font-family: Roboto; + font-style: italic; + font-weight: 400; + src: url("/factorio/fonts/Roboto-Italic.ttf") format("woff2"); +} + +@font-face { + font-display: swap; + font-family: Roboto; + font-style: normal; + font-weight: 500; + src: url("/factorio/fonts/Roboto-Medium.ttf") format("woff2"); +} + +@font-face { + font-display: swap; + font-family: Roboto; + font-style: italic; + font-weight: 500; + src: url("/factorio/fonts/Roboto-MediumItalic.ttf") format("woff2"); +} diff --git a/styles/globals.css b/styles/globals.css index 08c2756..ffed8fe 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -17,9 +17,9 @@ body { } body { - padding: 2em; - background: #fafafa; - color: black; + padding: 0 2em; + background: var(--md-sys-color-background); + color: var(--md-sys-color-on-background); } body.scroll { @@ -50,15 +50,14 @@ h4 { margin-block: 1em 0.3em; } +strong { + font-weight: 500; +} + @media (prefers-color-scheme: dark) { html { color-scheme: dark; } - - body { - background: #111; - color: white; - } } @media (max-width: 1200px) { diff --git a/styles/theme.css b/styles/theme.css new file mode 100644 index 0000000..9d69e48 --- /dev/null +++ b/styles/theme.css @@ -0,0 +1,5 @@ +@import "tokens.css"; +@import "colors.module.css"; +@import "typography.module.css"; +@import "theme.light.css" (prefers-color-scheme: light); +@import "theme.dark.css" (prefers-color-scheme: dark); diff --git a/styles/theme.dark.css b/styles/theme.dark.css new file mode 100644 index 0000000..e50ece3 --- /dev/null +++ b/styles/theme.dark.css @@ -0,0 +1,31 @@ +:root { + --md-sys-color-primary: var(--md-sys-color-primary-dark); + --md-sys-color-on-primary: var(--md-sys-color-on-primary-dark); + --md-sys-color-primary-container: var(--md-sys-color-primary-container-dark); + --md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-dark); + --md-sys-color-secondary: var(--md-sys-color-secondary-dark); + --md-sys-color-on-secondary: var(--md-sys-color-on-secondary-dark); + --md-sys-color-secondary-container: var(--md-sys-color-secondary-container-dark); + --md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-dark); + --md-sys-color-tertiary: var(--md-sys-color-tertiary-dark); + --md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-dark); + --md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-dark); + --md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-dark); + --md-sys-color-error: var(--md-sys-color-error-dark); + --md-sys-color-error-container: var(--md-sys-color-error-container-dark); + --md-sys-color-on-error: var(--md-sys-color-on-error-dark); + --md-sys-color-on-error-container: var(--md-sys-color-on-error-container-dark); + --md-sys-color-background: var(--md-sys-color-background-dark); + --md-sys-color-on-background: var(--md-sys-color-on-background-dark); + --md-sys-color-surface: var(--md-sys-color-surface-dark); + --md-sys-color-on-surface: var(--md-sys-color-on-surface-dark); + --md-sys-color-surface-variant: var(--md-sys-color-surface-variant-dark); + --md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-dark); + --md-sys-color-outline: var(--md-sys-color-outline-dark); + --md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-dark); + --md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-dark); + --md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-dark); + --md-sys-color-shadow: var(--md-sys-color-shadow-dark); + --md-sys-color-surface-tint: var(--md-sys-color-surface-tint-dark); + --md-sys-color-surface-tint-color: var(--md-sys-color-surface-tint-color-dark); +} diff --git a/styles/theme.light.css b/styles/theme.light.css new file mode 100644 index 0000000..4b513f0 --- /dev/null +++ b/styles/theme.light.css @@ -0,0 +1,31 @@ +:root { + --md-sys-color-primary: var(--md-sys-color-primary-light); + --md-sys-color-on-primary: var(--md-sys-color-on-primary-light); + --md-sys-color-primary-container: var(--md-sys-color-primary-container-light); + --md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-light); + --md-sys-color-secondary: var(--md-sys-color-secondary-light); + --md-sys-color-on-secondary: var(--md-sys-color-on-secondary-light); + --md-sys-color-secondary-container: var(--md-sys-color-secondary-container-light); + --md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-light); + --md-sys-color-tertiary: var(--md-sys-color-tertiary-light); + --md-sys-color-on-tertiary: var(--md-sys-color-on-tertiary-light); + --md-sys-color-tertiary-container: var(--md-sys-color-tertiary-container-light); + --md-sys-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container-light); + --md-sys-color-error: var(--md-sys-color-error-light); + --md-sys-color-error-container: var(--md-sys-color-error-container-light); + --md-sys-color-on-error: var(--md-sys-color-on-error-light); + --md-sys-color-on-error-container: var(--md-sys-color-on-error-container-light); + --md-sys-color-background: var(--md-sys-color-background-light); + --md-sys-color-on-background: var(--md-sys-color-on-background-light); + --md-sys-color-surface: var(--md-sys-color-surface-light); + --md-sys-color-on-surface: var(--md-sys-color-on-surface-light); + --md-sys-color-surface-variant: var(--md-sys-color-surface-variant-light); + --md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-light); + --md-sys-color-outline: var(--md-sys-color-outline-light); + --md-sys-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface-light); + --md-sys-color-inverse-surface: var(--md-sys-color-inverse-surface-light); + --md-sys-color-inverse-primary: var(--md-sys-color-inverse-primary-light); + --md-sys-color-shadow: var(--md-sys-color-shadow-light); + --md-sys-color-surface-tint: var(--md-sys-color-surface-tint-light); + --md-sys-color-surface-tint-color: var(--md-sys-color-surface-tint-color-light); +} diff --git a/styles/tokens.css b/styles/tokens.css new file mode 100644 index 0000000..774dc2d --- /dev/null +++ b/styles/tokens.css @@ -0,0 +1,293 @@ +:root { + --md-source: #e69100; + + /* primary */ + --md-ref-palette-primary0: #000; + --md-ref-palette-primary10: #2b1700; + --md-ref-palette-primary20: #472a00; + --md-ref-palette-primary25: #563400; + --md-ref-palette-primary30: #663e00; + --md-ref-palette-primary35: #764800; + --md-ref-palette-primary40: #865300; + --md-ref-palette-primary50: #a86900; + --md-ref-palette-primary60: #cb8000; + --md-ref-palette-primary70: #ef980f; + --md-ref-palette-primary80: #ffb963; + --md-ref-palette-primary90: #ffddb9; + --md-ref-palette-primary95: #ffeedf; + --md-ref-palette-primary98: #fff8f4; + --md-ref-palette-primary99: #fffbff; + --md-ref-palette-primary100: #fff; + + /* secondary */ + --md-ref-palette-secondary0: #000; + --md-ref-palette-secondary10: #001f2a; + --md-ref-palette-secondary20: #003546; + --md-ref-palette-secondary25: #004155; + --md-ref-palette-secondary30: #004d64; + --md-ref-palette-secondary35: #005a74; + --md-ref-palette-secondary40: #006684; + --md-ref-palette-secondary50: #0081a6; + --md-ref-palette-secondary60: #0d9cc8; + --md-ref-palette-secondary70: #42b7e4; + --md-ref-palette-secondary80: #69d3ff; + --md-ref-palette-secondary90: #bee9ff; + --md-ref-palette-secondary95: #e0f4ff; + --md-ref-palette-secondary98: #f4faff; + --md-ref-palette-secondary99: #fafcff; + --md-ref-palette-secondary100: #fff; + + /* tertiary */ + --md-ref-palette-tertiary0: #000; + --md-ref-palette-tertiary10: #002105; + --md-ref-palette-tertiary20: #00390e; + --md-ref-palette-tertiary25: #004613; + --md-ref-palette-tertiary30: #005318; + --md-ref-palette-tertiary35: #00601d; + --md-ref-palette-tertiary40: #0a6e24; + --md-ref-palette-tertiary50: #2f883b; + --md-ref-palette-tertiary60: #4ba352; + --md-ref-palette-tertiary70: #66be6a; + --md-ref-palette-tertiary80: #81da83; + --md-ref-palette-tertiary90: #9cf79c; + --md-ref-palette-tertiary95: #c7ffc2; + --md-ref-palette-tertiary98: #ebffe5; + --md-ref-palette-tertiary99: #f6fff0; + --md-ref-palette-tertiary100: #fff; + + /* neutral */ + --md-ref-palette-neutral0: #000; + --md-ref-palette-neutral10: #2b1700; + --md-ref-palette-neutral20: #472a00; + --md-ref-palette-neutral25: #573300; + --md-ref-palette-neutral30: #663e00; + --md-ref-palette-neutral35: #764800; + --md-ref-palette-neutral40: #875300; + --md-ref-palette-neutral50: #a86900; + --md-ref-palette-neutral60: #c8811e; + --md-ref-palette-neutral70: #e79b38; + --md-ref-palette-neutral80: #ffb963; + --md-ref-palette-neutral90: #ffddb9; + --md-ref-palette-neutral95: #ffeedf; + --md-ref-palette-neutral98: #fff8f4; + --md-ref-palette-neutral99: #fffbff; + --md-ref-palette-neutral100: #fff; + + /* neutral-variant */ + --md-ref-palette-neutral-variant0: #000; + --md-ref-palette-neutral-variant10: #231a11; + --md-ref-palette-neutral-variant20: #392f24; + --md-ref-palette-neutral-variant25: #443a2f; + --md-ref-palette-neutral-variant30: #504539; + --md-ref-palette-neutral-variant35: #5c5045; + --md-ref-palette-neutral-variant40: #685c50; + --md-ref-palette-neutral-variant50: #827568; + --md-ref-palette-neutral-variant60: #9d8e81; + --md-ref-palette-neutral-variant70: #b8a99a; + --md-ref-palette-neutral-variant80: #d4c4b5; + --md-ref-palette-neutral-variant90: #f1e0d0; + --md-ref-palette-neutral-variant95: #ffeedf; + --md-ref-palette-neutral-variant98: #fff8f4; + --md-ref-palette-neutral-variant99: #fffbff; + --md-ref-palette-neutral-variant100: #fff; + + /* error */ + --md-ref-palette-error0: #000; + --md-ref-palette-error10: #410002; + --md-ref-palette-error20: #690005; + --md-ref-palette-error25: #7e0007; + --md-ref-palette-error30: #93000a; + --md-ref-palette-error35: #a80710; + --md-ref-palette-error40: #ba1a1a; + --md-ref-palette-error50: #de3730; + --md-ref-palette-error60: #ff5449; + --md-ref-palette-error70: #ff897d; + --md-ref-palette-error80: #ffb4ab; + --md-ref-palette-error90: #ffdad6; + --md-ref-palette-error95: #ffedea; + --md-ref-palette-error98: #fff8f7; + --md-ref-palette-error99: #fffbff; + --md-ref-palette-error100: #fff; + + /* light */ + --md-sys-color-primary-light: #865300; + --md-sys-color-on-primary-light: #fff; + --md-sys-color-primary-container-light: #ffddb9; + --md-sys-color-on-primary-container-light: #2b1700; + --md-sys-color-secondary-light: #006684; + --md-sys-color-on-secondary-light: #fff; + --md-sys-color-secondary-container-light: #bee9ff; + --md-sys-color-on-secondary-container-light: #001f2a; + --md-sys-color-tertiary-light: #0a6e24; + --md-sys-color-on-tertiary-light: #fff; + --md-sys-color-tertiary-container-light: #9cf79c; + --md-sys-color-on-tertiary-container-light: #002105; + --md-sys-color-error-light: #ba1a1a; + --md-sys-color-error-container-light: #ffdad6; + --md-sys-color-on-error-light: #fff; + --md-sys-color-on-error-container-light: #410002; + --md-sys-color-background-light: #fffbff; + --md-sys-color-on-background-light: #2b1700; + --md-sys-color-surface-light: #fffbff; + --md-sys-color-on-surface-light: #2b1700; + --md-sys-color-surface-variant-light: #f1e0d0; + --md-sys-color-on-surface-variant-light: #504539; + --md-sys-color-outline-light: #827568; + --md-sys-color-inverse-on-surface-light: #ffeedf; + --md-sys-color-inverse-surface-light: #472a00; + --md-sys-color-inverse-primary-light: #ffb963; + --md-sys-color-shadow-light: #000; + --md-sys-color-surface-tint-light: #865300; + --md-sys-color-surface-tint-color-light: #865300; + + /* dark */ + --md-sys-color-primary-dark: #ffb963; + --md-sys-color-on-primary-dark: #472a00; + --md-sys-color-primary-container-dark: #663e00; + --md-sys-color-on-primary-container-dark: #ffddb9; + --md-sys-color-secondary-dark: #69d3ff; + --md-sys-color-on-secondary-dark: #003546; + --md-sys-color-secondary-container-dark: #004d64; + --md-sys-color-on-secondary-container-dark: #bee9ff; + --md-sys-color-tertiary-dark: #81da83; + --md-sys-color-on-tertiary-dark: #00390e; + --md-sys-color-tertiary-container-dark: #005318; + --md-sys-color-on-tertiary-container-dark: #9cf79c; + --md-sys-color-error-dark: #ffb4ab; + --md-sys-color-error-container-dark: #93000a; + --md-sys-color-on-error-dark: #690005; + --md-sys-color-on-error-container-dark: #ffdad6; + --md-sys-color-background-dark: #2b1700; + --md-sys-color-on-background-dark: #ffddb9; + --md-sys-color-surface-dark: #2b1700; + --md-sys-color-on-surface-dark: #ffddb9; + --md-sys-color-surface-variant-dark: #504539; + --md-sys-color-on-surface-variant-dark: #d4c4b5; + --md-sys-color-outline-dark: #9d8e81; + --md-sys-color-inverse-on-surface-dark: #2b1700; + --md-sys-color-inverse-surface-dark: #ffddb9; + --md-sys-color-inverse-primary-dark: #865300; + --md-sys-color-shadow-dark: #000; + --md-sys-color-surface-tint-dark: #ffb963; + --md-sys-color-surface-tint-color-dark: #ffb963; + + /* label - small */ + --md-sys-typescale-label-small-font-family-name: roboto; + --md-sys-typescale-label-small-font-family-style: normal; + --md-sys-typescale-label-small-font-weight: 500; + --md-sys-typescale-label-small-font-size: 11px; + --md-sys-typescale-label-small-letter-spacing: 0.5px; + --md-sys-typescale-label-small-line-height: 16px; + + /* label - medium */ + --md-sys-typescale-label-medium-font-family-name: roboto; + --md-sys-typescale-label-medium-font-family-style: normal; + --md-sys-typescale-label-medium-font-weight: 500; + --md-sys-typescale-label-medium-font-size: 12px; + --md-sys-typescale-label-medium-letter-spacing: 0.5px; + --md-sys-typescale-label-medium-line-height: 16px; + + /* label - large */ + --md-sys-typescale-label-large-font-family-name: roboto; + --md-sys-typescale-label-large-font-family-style: normal; + --md-sys-typescale-label-large-font-weight: 500; + --md-sys-typescale-label-large-font-size: 14px; + --md-sys-typescale-label-large-letter-spacing: 0.1px; + --md-sys-typescale-label-large-line-height: 20px; + + /* body - small */ + --md-sys-typescale-body-small-font-family-name: roboto; + --md-sys-typescale-body-small-font-family-style: normal; + --md-sys-typescale-body-small-font-weight: 400; + --md-sys-typescale-body-small-font-size: 12px; + --md-sys-typescale-body-small-letter-spacing: 0.4px; + --md-sys-typescale-body-small-line-height: 16px; + + /* body - medium */ + --md-sys-typescale-body-medium-font-family-name: roboto; + --md-sys-typescale-body-medium-font-family-style: normal; + --md-sys-typescale-body-medium-font-weight: 400; + --md-sys-typescale-body-medium-font-size: 14px; + --md-sys-typescale-body-medium-letter-spacing: 0.25px; + --md-sys-typescale-body-medium-line-height: 20px; + + /* body - large */ + --md-sys-typescale-body-large-font-family-name: roboto; + --md-sys-typescale-body-large-font-family-style: normal; + --md-sys-typescale-body-large-font-weight: 400; + --md-sys-typescale-body-large-font-size: 16px; + --md-sys-typescale-body-large-letter-spacing: 0.5px; + --md-sys-typescale-body-large-line-height: 24px; + + /* headline - small */ + --md-sys-typescale-headline-small-font-family-name: roboto; + --md-sys-typescale-headline-small-font-family-style: normal; + --md-sys-typescale-headline-small-font-weight: 400; + --md-sys-typescale-headline-small-font-size: 24px; + --md-sys-typescale-headline-small-letter-spacing: 0; + --md-sys-typescale-headline-small-line-height: 32px; + + /* headline - medium */ + --md-sys-typescale-headline-medium-font-family-name: roboto; + --md-sys-typescale-headline-medium-font-family-style: normal; + --md-sys-typescale-headline-medium-font-weight: 400; + --md-sys-typescale-headline-medium-font-size: 28px; + --md-sys-typescale-headline-medium-letter-spacing: 0; + --md-sys-typescale-headline-medium-line-height: 36px; + + /* headline - large */ + --md-sys-typescale-headline-large-font-family-name: roboto; + --md-sys-typescale-headline-large-font-family-style: normal; + --md-sys-typescale-headline-large-font-weight: 400; + --md-sys-typescale-headline-large-font-size: 32px; + --md-sys-typescale-headline-large-letter-spacing: 0; + --md-sys-typescale-headline-large-line-height: 40px; + + /* display - small */ + --md-sys-typescale-display-small-font-family-name: roboto; + --md-sys-typescale-display-small-font-family-style: normal; + --md-sys-typescale-display-small-font-weight: 400; + --md-sys-typescale-display-small-font-size: 36px; + --md-sys-typescale-display-small-letter-spacing: 0; + --md-sys-typescale-display-small-line-height: 44px; + + /* display - medium */ + --md-sys-typescale-display-medium-font-family-name: roboto; + --md-sys-typescale-display-medium-font-family-style: normal; + --md-sys-typescale-display-medium-font-weight: 400; + --md-sys-typescale-display-medium-font-size: 45px; + --md-sys-typescale-display-medium-letter-spacing: 0; + --md-sys-typescale-display-medium-line-height: 52px; + + /* display - large */ + --md-sys-typescale-display-large-font-family-name: roboto; + --md-sys-typescale-display-large-font-family-style: normal; + --md-sys-typescale-display-large-font-weight: 400; + --md-sys-typescale-display-large-font-size: 57px; + --md-sys-typescale-display-large-letter-spacing: -0.25px; + --md-sys-typescale-display-large-line-height: 64px; + + /* title - small */ + --md-sys-typescale-title-small-font-family-name: roboto; + --md-sys-typescale-title-small-font-family-style: normal; + --md-sys-typescale-title-small-font-weight: 500; + --md-sys-typescale-title-small-font-size: 14px; + --md-sys-typescale-title-small-letter-spacing: 0.1px; + --md-sys-typescale-title-small-line-height: 20px; + + /* title - medium */ + --md-sys-typescale-title-medium-font-family-name: roboto; + --md-sys-typescale-title-medium-font-family-style: normal; + --md-sys-typescale-title-medium-font-weight: 500; + --md-sys-typescale-title-medium-font-size: 16px; + --md-sys-typescale-title-medium-letter-spacing: 0.15px; + --md-sys-typescale-title-medium-line-height: 24px; + + /* title - large */ + --md-sys-typescale-title-large-font-family-name: roboto; + --md-sys-typescale-title-large-font-family-style: normal; + --md-sys-typescale-title-large-font-weight: 400; + --md-sys-typescale-title-large-font-size: 22px; + --md-sys-typescale-title-large-letter-spacing: 0; + --md-sys-typescale-title-large-line-height: 28px; +} diff --git a/styles/typography.module.css b/styles/typography.module.css new file mode 100644 index 0000000..542c080 --- /dev/null +++ b/styles/typography.module.css @@ -0,0 +1,134 @@ +.label-small { + font-family: var(--md-sys-typescale-label-small-font-family-name); + font-size: var(--md-sys-typescale-label-small-font-size); + font-style: var(--md-sys-typescale-label-small-font-family-style); + font-weight: var(--md-sys-typescale-label-small-font-weight); + letter-spacing: var(--md-sys-typescale-label-small-letter-spacing); + line-height: var(--md-sys-typescale-label-small-line-height); +} + +.label-medium { + font-family: var(--md-sys-typescale-label-medium-font-family-name); + font-size: var(--md-sys-typescale-label-medium-font-size); + font-style: var(--md-sys-typescale-label-medium-font-family-style); + font-weight: var(--md-sys-typescale-label-medium-font-weight); + letter-spacing: var(--md-sys-typescale-label-medium-letter-spacing); + line-height: var(--md-sys-typescale-label-medium-line-height); +} + +.label-large { + font-family: var(--md-sys-typescale-label-large-font-family-name); + font-size: var(--md-sys-typescale-label-large-font-size); + font-style: var(--md-sys-typescale-label-large-font-family-style); + font-weight: var(--md-sys-typescale-label-large-font-weight); + letter-spacing: var(--md-sys-typescale-label-large-letter-spacing); + line-height: var(--md-sys-typescale-label-large-line-height); +} + +.body-small { + font-family: var(--md-sys-typescale-body-small-font-family-name); + font-size: var(--md-sys-typescale-body-small-font-size); + font-style: var(--md-sys-typescale-body-small-font-family-style); + font-weight: var(--md-sys-typescale-body-small-font-weight); + letter-spacing: var(--md-sys-typescale-body-small-letter-spacing); + line-height: var(--md-sys-typescale-body-small-line-height); +} + +.body-medium { + font-family: var(--md-sys-typescale-body-medium-font-family-name); + font-size: var(--md-sys-typescale-body-medium-font-size); + font-style: var(--md-sys-typescale-body-medium-font-family-style); + font-weight: var(--md-sys-typescale-body-medium-font-weight); + letter-spacing: var(--md-sys-typescale-body-medium-letter-spacing); + line-height: var(--md-sys-typescale-body-medium-line-height); +} + +.body-large { + font-family: var(--md-sys-typescale-body-large-font-family-name); + font-size: var(--md-sys-typescale-body-large-font-size); + font-style: var(--md-sys-typescale-body-large-font-family-style); + font-weight: var(--md-sys-typescale-body-large-font-weight); + letter-spacing: var(--md-sys-typescale-body-large-letter-spacing); + line-height: var(--md-sys-typescale-body-large-line-height); +} + +.headline-small { + font-family: var(--md-sys-typescale-headline-small-font-family-name); + font-size: var(--md-sys-typescale-headline-small-font-size); + font-style: var(--md-sys-typescale-headline-small-font-family-style); + font-weight: var(--md-sys-typescale-headline-small-font-weight); + letter-spacing: var(--md-sys-typescale-headline-small-letter-spacing); + line-height: var(--md-sys-typescale-headline-small-line-height); +} + +.headline-medium { + font-family: var(--md-sys-typescale-headline-medium-font-family-name); + font-size: var(--md-sys-typescale-headline-medium-font-size); + font-style: var(--md-sys-typescale-headline-medium-font-family-style); + font-weight: var(--md-sys-typescale-headline-medium-font-weight); + letter-spacing: var(--md-sys-typescale-headline-medium-letter-spacing); + line-height: var(--md-sys-typescale-headline-medium-line-height); +} + +.headline-large { + font-family: var(--md-sys-typescale-headline-large-font-family-name); + font-size: var(--md-sys-typescale-headline-large-font-size); + font-style: var(--md-sys-typescale-headline-large-font-family-style); + font-weight: var(--md-sys-typescale-headline-large-font-weight); + letter-spacing: var(--md-sys-typescale-headline-large-letter-spacing); + line-height: var(--md-sys-typescale-headline-large-line-height); +} + +.display-small { + font-family: var(--md-sys-typescale-display-small-font-family-name); + font-size: var(--md-sys-typescale-display-small-font-size); + font-style: var(--md-sys-typescale-display-small-font-family-style); + font-weight: var(--md-sys-typescale-display-small-font-weight); + letter-spacing: var(--md-sys-typescale-display-small-letter-spacing); + line-height: var(--md-sys-typescale-display-small-line-height); +} + +.display-medium { + font-family: var(--md-sys-typescale-display-medium-font-family-name); + font-size: var(--md-sys-typescale-display-medium-font-size); + font-style: var(--md-sys-typescale-display-medium-font-family-style); + font-weight: var(--md-sys-typescale-display-medium-font-weight); + letter-spacing: var(--md-sys-typescale-display-medium-letter-spacing); + line-height: var(--md-sys-typescale-display-medium-line-height); +} + +.display-large { + font-family: var(--md-sys-typescale-display-large-font-family-name); + font-size: var(--md-sys-typescale-display-large-font-size); + font-style: var(--md-sys-typescale-display-large-font-family-style); + font-weight: var(--md-sys-typescale-display-large-font-weight); + letter-spacing: var(--md-sys-typescale-display-large-letter-spacing); + line-height: var(--md-sys-typescale-display-large-line-height); +} + +.title-small { + font-family: var(--md-sys-typescale-title-small-font-family-name); + font-size: var(--md-sys-typescale-title-small-font-size); + font-style: var(--md-sys-typescale-title-small-font-family-style); + font-weight: var(--md-sys-typescale-title-small-font-weight); + letter-spacing: var(--md-sys-typescale-title-small-letter-spacing); + line-height: var(--md-sys-typescale-title-small-line-height); +} + +.title-medium { + font-family: var(--md-sys-typescale-title-medium-font-family-name); + font-size: var(--md-sys-typescale-title-medium-font-size); + font-style: var(--md-sys-typescale-title-medium-font-family-style); + font-weight: var(--md-sys-typescale-title-medium-font-weight); + letter-spacing: var(--md-sys-typescale-title-medium-letter-spacing); + line-height: var(--md-sys-typescale-title-medium-line-height); +} + +.title-large { + font-family: var(--md-sys-typescale-title-large-font-family-name); + font-size: var(--md-sys-typescale-title-large-font-size); + font-style: var(--md-sys-typescale-title-large-font-family-style); + font-weight: var(--md-sys-typescale-title-large-font-weight); + letter-spacing: var(--md-sys-typescale-title-large-letter-spacing); + line-height: var(--md-sys-typescale-title-large-line-height); +} diff --git a/tsconfig.json b/tsconfig.json index c4facb9..4075ada 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,5 @@ "incremental": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "scripts"] + "exclude": ["node_modules", "scripts", "styles/font-faces.css"] } diff --git a/yarn.lock b/yarn.lock index bc2dd8d..dd98c38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3510,6 +3510,11 @@ stylelint-order@^3.1.1: postcss "^7.0.17" postcss-sorting "^5.0.1" +stylelint-use-logical@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/stylelint-use-logical/-/stylelint-use-logical-2.0.0.tgz#9fa9cffacf3d86ea4867477b0599127b05552f6e" + integrity sha512-4wRXETzWSF3yc9znj28VOZZ+VyVys1jeb6L341tit3KkKuAqib1PkGq5lQK0Xf2NhdoHkEHCaFSJfCL8u6UTOA== + stylelint@^14.10.0: version "14.10.0" resolved "https://registry.npmjs.org/stylelint/-/stylelint-14.10.0.tgz"