From c9768bd8f8fd2c38b47d100bff5e1d9ec3d99f7d Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Tue, 20 Dec 2022 23:55:07 -0800 Subject: [PATCH] Add appearance setting for rounded corners. Closes #2471 --- web/pages/admin/config/appearance/index.tsx | 50 ++++++++++++++++--- .../tokens/color/default-theme.yaml | 2 +- web/styles/theme.less | 4 +- web/styles/variables.css | 4 +- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/web/pages/admin/config/appearance/index.tsx b/web/pages/admin/config/appearance/index.tsx index 84e2df234..4542c0e9b 100644 --- a/web/pages/admin/config/appearance/index.tsx +++ b/web/pages/admin/config/appearance/index.tsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; -import { Button, Col, Collapse, Row, Space } from 'antd'; +import { Button, Col, Collapse, Row, Slider, Space } from 'antd'; import Paragraph from 'antd/lib/typography/Paragraph'; import Title from 'antd/lib/typography/Title'; import { EditCustomStyles } from '../../../../components/config/EditCustomStyles'; @@ -97,6 +97,8 @@ export default function Appearance() { { name: 'theme-color-components-scrollbar-thumb', description: 'Scrollbar Thumb' }, ]; + const others = [{ name: 'theme-rounded-corners', description: 'Corner radius' }]; + const [colors, setColors] = useState>(); const [submitStatus, setSubmitStatus] = useState(null); @@ -109,12 +111,14 @@ export default function Appearance() { const setColorDefaults = () => { const c = {}; - [...paletteVariables, ...componentColorVariables, ...chatColorVariables].forEach(color => { - const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue( - `--${color.name}`, - ); - c[color.name] = { value: resolvedColor.trim(), description: color.description }; - }); + [...paletteVariables, ...componentColorVariables, ...chatColorVariables, ...others].forEach( + color => { + const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue( + `--${color.name}`, + ); + c[color.name] = { value: resolvedColor.trim(), description: color.description }; + }, + ); setColors(c); }; @@ -179,6 +183,12 @@ export default function Appearance() { return
Loading...
; } + const onBorderRadiusChange = (value: string) => { + const variableName = 'theme-rounded-corners'; + + updateColor(variableName, `${value.toString()}px`, ''); + }; + return ( Customize Appearance @@ -239,6 +249,32 @@ export default function Appearance() { })} + Other Settings} key="4"> + How rounded should corners be? + + + { + onBorderRadiusChange(v); + }} + value={Number(colors['theme-rounded-corners']?.value?.replace('px', '') || 0)} + /> + + +
+ + +
diff --git a/web/style-definitions/tokens/color/default-theme.yaml b/web/style-definitions/tokens/color/default-theme.yaml index b94bb62b5..4c7311657 100644 --- a/web/style-definitions/tokens/color/default-theme.yaml +++ b/web/style-definitions/tokens/color/default-theme.yaml @@ -5,7 +5,7 @@ theme: rounded-corners: - value: 0.5rem + value: 9px comment: 'How much corners are rounded in places in the UI.' unknown-1: value: 'green' diff --git a/web/styles/theme.less b/web/styles/theme.less index 71ff9912d..0e7318c7f 100644 --- a/web/styles/theme.less +++ b/web/styles/theme.less @@ -1,6 +1,6 @@ // Do not edit directly -// Generated on Sun, 13 Nov 2022 20:49:29 GMT +// Generated on Wed, 21 Dec 2022 07:38:01 GMT // // How to edit these values: // Edit the corresponding token file under the style-definitions directory @@ -30,7 +30,7 @@ @primary-8: #da9eff; // Fun color 2 @component-background: #e2e8f0; // Light primary @body-background: #e2e8f0; // Light primary -@theme-rounded-corners: 0.5rem; // How much corners are rounded in places in the UI. +@theme-rounded-corners: 9px; // How much corners are rounded in places in the UI. @theme-unknown-1: green; // This should never be used and it means something is wrong. @theme-unknown-2: red; // This should never be used and it means something is wrong. @theme-text-body-font-family: var(--font-owncast-body); // The font family used for the body text. diff --git a/web/styles/variables.css b/web/styles/variables.css index ee0aba4b7..950bcad1f 100644 --- a/web/styles/variables.css +++ b/web/styles/variables.css @@ -1,6 +1,6 @@ /** * Do not edit directly - * Generated on Sun, 13 Nov 2022 20:49:29 GMT + * Generated on Wed, 21 Dec 2022 07:38:01 GMT * * How to edit these values: * Edit the corresponding token file under the style-definitions directory @@ -32,7 +32,7 @@ --primary-8: #da9eff; /* Fun color 2 */ --component-background: #e2e8f0; /* Light primary */ --body-background: #e2e8f0; /* Light primary */ - --theme-rounded-corners: 0.5rem; /* How much corners are rounded in places in the UI. */ + --theme-rounded-corners: 9px; /* How much corners are rounded in places in the UI. */ --theme-unknown-1: green; /* This should never be used and it means something is wrong. */ --theme-unknown-2: red; /* This should never be used and it means something is wrong. */ --theme-text-body-font-family: var(--font-owncast-body); /* The font family used for the body text. */