From f505d876382b9468a49e9ca2f813c6a20225b3ea Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 28 Feb 2022 18:48:00 +0800 Subject: [PATCH] feat(console): implement sidebar --- packages/console/package.json | 13 ++++++---- packages/console/src/App.module.scss | 3 +++ .../Sidebar/components/Item/index.module.scss | 26 +++++++++++++++++++ .../Sidebar/components/Item/index.tsx | 19 ++++++++++++++ .../components/Section/index.module.scss | 10 +++++++ .../Sidebar/components/Section/index.tsx | 19 ++++++++++++++ .../src/components/Sidebar/icons/BarGraph.tsx | 11 ++++++++ .../src/components/Sidebar/icons/Bolt.tsx | 11 ++++++++ .../src/components/Sidebar/index.module.scss | 8 +++--- .../console/src/components/Sidebar/index.tsx | 17 +++++++++++- packages/console/src/scss/_underscore.scss | 6 +++++ packages/console/src/scss/normalized.scss | 4 ++- 12 files changed, 137 insertions(+), 10 deletions(-) create mode 100644 packages/console/src/components/Sidebar/components/Item/index.module.scss create mode 100644 packages/console/src/components/Sidebar/components/Item/index.tsx create mode 100644 packages/console/src/components/Sidebar/components/Section/index.module.scss create mode 100644 packages/console/src/components/Sidebar/components/Section/index.tsx create mode 100644 packages/console/src/components/Sidebar/icons/BarGraph.tsx create mode 100644 packages/console/src/components/Sidebar/icons/Bolt.tsx diff --git a/packages/console/package.json b/packages/console/package.json index 362e81c09..847946d28 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -42,13 +42,16 @@ "@/*": "./src/$1" }, "eslintConfig": { - "extends": "@silverhand/react" + "extends": "@silverhand/react", + "rules": { + "react/jsx-curly-brace-presence": [ + "error", + { "props": "never", "children": "never", "propElementValues": "always" } + ] + } }, "stylelint": { - "extends": "@silverhand/eslint-config-react/.stylelintrc", - "rules": { - "color-function-notation": "legacy" - } + "extends": "@silverhand/eslint-config-react/.stylelintrc" }, "prettier": "@silverhand/eslint-config/.prettierrc" } diff --git a/packages/console/src/App.module.scss b/packages/console/src/App.module.scss index 91d9cfa0c..fa0a04e94 100644 --- a/packages/console/src/App.module.scss +++ b/packages/console/src/App.module.scss @@ -1,4 +1,7 @@ .skeleton { + + // TO-DO: move to theme component + --color-on-surface-variant: #47464e; position: absolute; left: 0; top: 0; diff --git a/packages/console/src/components/Sidebar/components/Item/index.module.scss b/packages/console/src/components/Sidebar/components/Item/index.module.scss new file mode 100644 index 000000000..f39aaf59b --- /dev/null +++ b/packages/console/src/components/Sidebar/components/Item/index.module.scss @@ -0,0 +1,26 @@ +@use '@/scss/underscore' as _; + +.row { + display: flex; + align-items: center; + padding: _.unit(3) _.unit(6); + color: var(--color-on-surface-variant); + + > div + div { + margin-left: _.unit(5); + } + + .icon { + width: _.unit(6); + height: _.unit(6); + flex: 0 0 _.unit(6); + + svg { + fill: var(--color-on-surface-variant); + } + } + + .title { + @include _.subhead-1; + } +} diff --git a/packages/console/src/components/Sidebar/components/Item/index.tsx b/packages/console/src/components/Sidebar/components/Item/index.tsx new file mode 100644 index 000000000..c13e7e08b --- /dev/null +++ b/packages/console/src/components/Sidebar/components/Item/index.tsx @@ -0,0 +1,19 @@ +import React, { ReactChild } from 'react'; + +import * as styles from './index.module.scss'; + +type Props = { + icon?: ReactChild; + title: string; +}; + +const Item = ({ icon, title }: Props) => { + return ( +
+ {icon &&
{icon}
} +
{title}
+
+ ); +}; + +export default Item; diff --git a/packages/console/src/components/Sidebar/components/Section/index.module.scss b/packages/console/src/components/Sidebar/components/Section/index.module.scss new file mode 100644 index 000000000..105deccf7 --- /dev/null +++ b/packages/console/src/components/Sidebar/components/Section/index.module.scss @@ -0,0 +1,10 @@ +@use '@/scss/underscore' as _; + +.title { + font-weight: bold; + color: #adaab4; + padding: _.unit(3) _.unit(6); + text-transform: uppercase; + letter-spacing: 0.1em; + font-size: 12px; +} diff --git a/packages/console/src/components/Sidebar/components/Section/index.tsx b/packages/console/src/components/Sidebar/components/Section/index.tsx new file mode 100644 index 000000000..6f1068d30 --- /dev/null +++ b/packages/console/src/components/Sidebar/components/Section/index.tsx @@ -0,0 +1,19 @@ +import React, { ReactNode } from 'react'; + +import * as styles from './index.module.scss'; + +type Props = { + title: string; + children: ReactNode; +}; + +const Section = ({ children, title }: Props) => { + return ( +
+
{title}
+ {children} +
+ ); +}; + +export default Section; diff --git a/packages/console/src/components/Sidebar/icons/BarGraph.tsx b/packages/console/src/components/Sidebar/icons/BarGraph.tsx new file mode 100644 index 000000000..55ae3c4b8 --- /dev/null +++ b/packages/console/src/components/Sidebar/icons/BarGraph.tsx @@ -0,0 +1,11 @@ +import React from 'react'; + +const BarGraph = () => { + return ( + + + + ); +}; + +export default BarGraph; diff --git a/packages/console/src/components/Sidebar/icons/Bolt.tsx b/packages/console/src/components/Sidebar/icons/Bolt.tsx new file mode 100644 index 000000000..aacfb2fe3 --- /dev/null +++ b/packages/console/src/components/Sidebar/icons/Bolt.tsx @@ -0,0 +1,11 @@ +import React from 'react'; + +const Bolt = () => { + return ( + + + + ); +}; + +export default Bolt; diff --git a/packages/console/src/components/Sidebar/index.module.scss b/packages/console/src/components/Sidebar/index.module.scss index 871f5a2d2..3f300fba5 100644 --- a/packages/console/src/components/Sidebar/index.module.scss +++ b/packages/console/src/components/Sidebar/index.module.scss @@ -1,9 +1,11 @@ @use '@/scss/underscore' as _; .sidebar { - padding: _.unit(3); flex-grow: 0; flex-shrink: 0; - // TO-DO: remove after fulfilled with components - width: 250px; + width: 275px; + + > div + div { + margin-top: _.unit(6); + } } diff --git a/packages/console/src/components/Sidebar/index.tsx b/packages/console/src/components/Sidebar/index.tsx index 529d47c5b..74e630c36 100644 --- a/packages/console/src/components/Sidebar/index.tsx +++ b/packages/console/src/components/Sidebar/index.tsx @@ -1,9 +1,24 @@ import React from 'react'; +import Item from './components/Item'; +import Section from './components/Section'; +import BarGraph from './icons/BarGraph'; +import Bolt from './icons/Bolt'; import * as styles from './index.module.scss'; const Sidebar = () => { - return
Sidebar
; + return ( +
+
+ } title="Get Started" /> + } title="Dashboard" /> +
+
+ } title="Get Started" /> + } title="Dashboard" /> +
+
+ ); }; export default Sidebar; diff --git a/packages/console/src/scss/_underscore.scss b/packages/console/src/scss/_underscore.scss index 8f5c5b957..7387336b0 100644 --- a/packages/console/src/scss/_underscore.scss +++ b/packages/console/src/scss/_underscore.scss @@ -8,3 +8,9 @@ align-items: center; justify-content: center; } + +@mixin subhead-1 { + font-weight: 500; + font-size: 16px; + line-height: 24px; +} diff --git a/packages/console/src/scss/normalized.scss b/packages/console/src/scss/normalized.scss index 2f6b901fd..2a3fe0785 100644 --- a/packages/console/src/scss/normalized.scss +++ b/packages/console/src/scss/normalized.scss @@ -1,8 +1,10 @@ body { margin: 0; padding: 0; - font-family: sans-serif; + font-family: 'SF UI Text', 'SF Pro Display', sans-serif; background: rgb(#e5e1ec, 50%); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: auto; } * {