From 5bfc16fec3c6a96ce51dff8d46b4c2ea798b75c0 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Tue, 30 Jul 2024 22:56:46 +0200 Subject: [PATCH 01/18] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20package=20ver?= =?UTF-8?q?sion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6af96dc..0e33220 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webcoreui", "type": "module", - "version": "0.0.12", + "version": "0.1.0", "scripts": { "dev": "astro dev", "build": "astro check && astro build", From 64d9d3daf53a5bb7d5ae414e190584e9b859bcab Mon Sep 17 00:00:00 2001 From: Frontendland Date: Wed, 31 Jul 2024 09:21:45 +0200 Subject: [PATCH 02/18] =?UTF-8?q?=F0=9F=90=9B=20Fix=20React=20types=20for?= =?UTF-8?q?=20TimelineItem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/buildTypes.js | 1 - src/components/TimelineItem/TimelineItem.tsx | 7 +------ src/components/TimelineItem/timelineitem.ts | 5 +++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/buildTypes.js b/scripts/buildTypes.js index ec59c18..7378210 100644 --- a/scripts/buildTypes.js +++ b/scripts/buildTypes.js @@ -57,7 +57,6 @@ const buildTypes = type => { 'Rating', 'Spinner', 'Table', - 'TimelineItem', 'Progress' ] diff --git a/src/components/TimelineItem/TimelineItem.tsx b/src/components/TimelineItem/TimelineItem.tsx index ca2b666..de18dbf 100644 --- a/src/components/TimelineItem/TimelineItem.tsx +++ b/src/components/TimelineItem/TimelineItem.tsx @@ -1,14 +1,9 @@ import React from 'react' -import type { TimelineItemProps } from './timelineitem' +import type { ReactTimelineItemProps } from './timelineitem' import styles from './timelineitem.module.scss' import { classNames } from '../../utils/classNames' -type ReactTimelineItemProps = { - TitleTag?: keyof JSX.IntrinsicElements - children: React.ReactNode -} & Omit - const TimelineItem = ({ title, TitleTag = 'span', diff --git a/src/components/TimelineItem/timelineitem.ts b/src/components/TimelineItem/timelineitem.ts index 306d2a8..ba4df0c 100644 --- a/src/components/TimelineItem/timelineitem.ts +++ b/src/components/TimelineItem/timelineitem.ts @@ -3,3 +3,8 @@ export type TimelineItemProps = { titleTag?: string className?: string } + +export type ReactTimelineItemProps = { + TitleTag?: keyof JSX.IntrinsicElements + children: React.ReactNode +} & Omit From 77c088fc6a603179532ee76c022ec6ae727cd2a3 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Thu, 1 Aug 2024 16:03:12 +0200 Subject: [PATCH 03/18] =?UTF-8?q?=F0=9F=92=84=20Adjust=20alert=20alignment?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Alert/alert.module.scss | 4 ++-- src/pages/alert.astro | 6 +++++- src/scss/resets.scss | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Alert/alert.module.scss b/src/components/Alert/alert.module.scss index dd1197c..b0a0ff4 100644 --- a/src/components/Alert/alert.module.scss +++ b/src/components/Alert/alert.module.scss @@ -37,11 +37,11 @@ svg { @include size(20px); min-width: 20px; - margin-top: 1px; + margin-top: 2.5px; } .title { - @include spacing(mb-xs); + @include typography(hmd); display: block; } diff --git a/src/pages/alert.astro b/src/pages/alert.astro index d2540cd..994cb0f 100644 --- a/src/pages/alert.astro +++ b/src/pages/alert.astro @@ -72,7 +72,7 @@ const sections = getSections({ - Predefined info theme alert without title. + Predefined info theme alert without title. @@ -82,6 +82,10 @@ const sections = getSections({ Predefined warning theme alert without title and multiple lines, to demonstrate the behavior of layout with large amounts of text. + + + Predefined info theme alert with long title and multiple lines, to demonstrate the behavior of layout with large amounts of text. + ))} diff --git a/src/scss/resets.scss b/src/scss/resets.scss index 4b1a0ae..4a4bf9b 100644 --- a/src/scss/resets.scss +++ b/src/scss/resets.scss @@ -57,7 +57,7 @@ } code { - @include spacing(py-xxs, px-sm, my-xxs); + @include spacing(px-sm); display: inline-block; } From 9143a5c90f1c2521de02ed1e00a34b08a6e1594d Mon Sep 17 00:00:00 2001 From: Frontendland Date: Thu, 1 Aug 2024 17:06:52 +0200 Subject: [PATCH 04/18] =?UTF-8?q?=E2=9C=A8=20Add=20utility=20classes=20for?= =?UTF-8?q?=20flexbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/pages/resets.astro | 2 +- src/pages/utilities.astro | 122 +++++++++++++++++++++++++++++++ src/scss/global/utility.scss | 134 ++++++++++++++++++++--------------- src/scss/setup.scss | 4 +- src/static/Box.astro | 14 ++++ 6 files changed, 216 insertions(+), 62 deletions(-) create mode 100644 src/pages/utilities.astro create mode 100644 src/static/Box.astro diff --git a/README.md b/README.md index 9b8e85e..9cc6998 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ The `Setup` mixin can also accept the following options: | Property | Default value | Purpose | |-----------|---------------|---------| | `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. | -| `includeHelperClasses` | `true` | Adds global helper classes for CSS. All global helper classes are defined [here](https://github.com/Frontendland/webcoreui/tree/main/src/scss/global). | +| `includeUtilities` | `true` | Adds utility classes for CSS. Read more about the available utility classes [here](https://webcoreui.dev/docs/layout). | | `includeTooltip` | `true` | Adds styles for using tooltips. | `includeScrollbarStyles` | `true` | Adds styles for scrollbars. diff --git a/src/pages/resets.astro b/src/pages/resets.astro index aac7364..add828d 100644 --- a/src/pages/resets.astro +++ b/src/pages/resets.astro @@ -4,7 +4,7 @@ import Card from '@components/Card/Card.astro' --- -

Reset styles

+

CSS Resets

diff --git a/src/pages/utilities.astro b/src/pages/utilities.astro new file mode 100644 index 0000000..185d4f3 --- /dev/null +++ b/src/pages/utilities.astro @@ -0,0 +1,122 @@ +--- +import Layout from '@static/Layout.astro' +import Box from '@static/Box.astro' + +import Card from '@components/Card/Card.astro' + +const spacings = [ + 'xxs', + 'xs', + 'sm', + 'md', + 'default', + 'lg', + 'xl', + 'xl2', + 'xl3', + 'xl4', + 'xl5' +] + +const flexDirections = [ + 'row', + 'column', + 'row-reverse', + 'column-reverse', +] + +const verticalAlignments = [ + 'items-center', + 'items-start', + 'items-end' +] + +const horizontalAlignments = [ + 'justify-center', + 'justify-start', + 'justify-end', + 'justify-between', + 'justify-around', + 'justify-evenly' +] + +const wraps = [ + 'wrap', + 'nowrap', + 'wrap-reverse' +] +--- + + +

CSS Utility Classes

+ +

Container

+ +
+
.container with a max-width and padding
+
+
+ +

Flex

+ + {spacings.map(space => ( +
+ {space} + + + + +
+ ))} +
+
+ {flexDirections.map(direction => ( + +
+ 1 + 2 + 3 + 4 +
+
+ ))} +
+
+ {verticalAlignments.map(alignment => ( + +
+ 1 + 2 + 3 +
+
+ ))} +
+
+ {horizontalAlignments.map(alignment => ( + +
+ 1 + 2 + 3 +
+
+ ))} +
+
+ {wraps.map(wrap => ( + +
+ 1 + 2 + 3 + 4 + 5 +
+
+ ))} +
+
diff --git a/src/scss/global/utility.scss b/src/scss/global/utility.scss index ad398f3..4e83c80 100644 --- a/src/scss/global/utility.scss +++ b/src/scss/global/utility.scss @@ -1,88 +1,106 @@ +@use 'sass:string'; +@use 'sass:meta'; +@use 'sass:list'; +@use 'sass:map'; @use '../config' as *; +$breakpointMap: ( + 'xs': 3, + 'sm': 4, + 'md': 6, + 'lg': 8 +); + +$alignments: ( + 'items-center': center, + 'items-start': flex-start, + 'items-end': flex-end, + 'items-baseline': baseline, + 'items-stretch': stretch, + + 'justify-center': center, + 'justify-start': flex-start, + 'justify-end': flex-end, + 'justify-between': space-between, + 'justify-around': space-around, + 'justify-evenly': space-evenly, + 'justify-stretch': stretch +); + @mixin utility() { .container { - margin: 0 auto; + @include spacing(auto-none, px-default); max-width: 1200px; - padding: 0 20px; } - .grid { - display: grid; - gap: 20px; - - &.col-2 { - grid-template-columns: repeat(2, minmax(0, 1fr)); + // Gaps + .flex, .grid { + @each $key, $value in $spacing { + $numberList: ('2', '3', '4', '5'); + $firstLetter: string.slice($key, 1, 1); + $class: $key; + + @if (list.index($numberList, $firstLetter)) { + $class: string.slice($key, 2, -1) + $firstLetter; + } + + &.#{$class} { gap: $value; } } } - .flex { - display: flex; - gap: 20px; - - &.column { - flex-direction: column; - } - - &.xs { - gap: 5px; - } - - &.sm { - gap: 10px; - } - - &.wrap { - flex-wrap: wrap; - } - - &.center { - justify-content: center; - align-items: center; - } - - &.justify-center { - justify-content: center; - } - - &.items-center { - align-items: center; - } - - &.items-start { - align-items: flex-start; + // Alignments + @each $key, $value in $alignments { + .#{$key} { + @if (string.index($key, 'items')) { + align-items: $value; + } @else { + justify-content: $value; + } } } - .my { - margin: 20px auto; + .flex.center, + .grid.center { + justify-content: center; + align-items: center; } - @include media('md') { - .grid.md-2 { - grid-template-columns: repeat(2, minmax(0, 1fr)); - } + .flex { + @include layout(flex, default); - .grid.md-3 { - grid-template-columns: repeat(3, minmax(0, 1fr)); + @each $direction in $flexDirectionValues { + &.#{$direction} { + flex-direction: $direction; + } } - .grid.md-4 { - grid-template-columns: repeat(4, minmax(0, 1fr)); + @each $wrap in $flexWrapValues { + &.#{$wrap} { + flex-wrap: $wrap; + } } } - @include media('lg') { - .grid.lg-2 { + .grid { + @include layout(grid, default); + + &.col-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .grid.lg-3 { + &.col-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } + } - .grid.lg-4 { - grid-template-columns: repeat(4, minmax(0, 1fr)); + // Grid columns + @each $key, $value in $breakpoints { + @include media($key) { + @for $i from 2 to map.get($breakpointMap, $key) + 1 { + .grid.#{$key}-#{$i} { + grid-template-columns: repeat($i, minmax(0, 1fr)); + } + } } } } diff --git a/src/scss/setup.scss b/src/scss/setup.scss index 541dd4a..462ed86 100644 --- a/src/scss/setup.scss +++ b/src/scss/setup.scss @@ -2,7 +2,7 @@ $config: ( includeResets: true, - includeHelperClasses: true, + includeUtilities: true, includeTooltip: true, includeScrollbarStyles: true ); @@ -25,7 +25,7 @@ body { @include resets(); } - @if (config('includeHelperClasses')) { + @if (config('includeUtilities')) { @include utility(); } diff --git a/src/static/Box.astro b/src/static/Box.astro new file mode 100644 index 0000000..59d0181 --- /dev/null +++ b/src/static/Box.astro @@ -0,0 +1,14 @@ +
+ + From 58c00e285df0c1b48fc60485c54197a011c891a7 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Thu, 1 Aug 2024 17:16:58 +0200 Subject: [PATCH 05/18] =?UTF-8?q?=E2=9C=A8=20Accept=20active=20state=20for?= =?UTF-8?q?=20menu=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Menu/Menu.astro | 6 +++++- src/components/Menu/Menu.svelte | 6 +++++- src/components/Menu/Menu.tsx | 6 +++++- src/components/Menu/menu.module.scss | 4 ++++ src/components/Menu/menu.ts | 1 + src/static/Layout.astro | 18 ++++++++++++------ 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/components/Menu/Menu.astro b/src/components/Menu/Menu.astro index 97e56ec..208726a 100644 --- a/src/components/Menu/Menu.astro +++ b/src/components/Menu/Menu.astro @@ -54,7 +54,11 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has('
    {items.map(item => (
  • - + {item.name}
  • diff --git a/src/components/Menu/Menu.svelte b/src/components/Menu/Menu.svelte index e8ba567..46bcb62 100644 --- a/src/components/Menu/Menu.svelte +++ b/src/components/Menu/Menu.svelte @@ -50,7 +50,11 @@
      {#each items as item}
    • - + {item.name}
    • diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index 21e57c2..5a0e78e 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -62,7 +62,11 @@ const Menu = ({
        {items.map((item, index) => (
      • - + {item.name}
      • diff --git a/src/components/Menu/menu.module.scss b/src/components/Menu/menu.module.scss index 1b623da..0eb53dd 100644 --- a/src/components/Menu/menu.module.scss +++ b/src/components/Menu/menu.module.scss @@ -75,6 +75,10 @@ &:hover { @include typography(primary); } + + &.active { + @include typography(primary); + } } } diff --git a/src/components/Menu/menu.ts b/src/components/Menu/menu.ts index aaa1cca..85928d0 100644 --- a/src/components/Menu/menu.ts +++ b/src/components/Menu/menu.ts @@ -3,6 +3,7 @@ export type MenuProps = { url: string name: string target?: string + active?: boolean }[] logo?: { url?: string diff --git a/src/static/Layout.astro b/src/static/Layout.astro index a0dd079..fbe14c9 100644 --- a/src/static/Layout.astro +++ b/src/static/Layout.astro @@ -10,15 +10,17 @@ const menuClasses = [ ].filter(Boolean).join(' ') const theme = (Astro.cookies.get('w-theme')?.value || 'theme-dark') as string +const isPath = (path: string) => Astro.url.pathname.includes(path) const menu = { logo: { html: logo }, items: [ - { url: '/resets', name: 'Resets' }, - { url: '/svelte', name: 'Svelte' }, - { url: '/react', name: 'React' } + { url: '/svelte', name: 'Svelte', active: isPath('svelte') }, + { url: '/react', name: 'React', active: isPath('react') }, + { url: '/resets', name: 'Resets', active: isPath('resets') }, + { url: '/utilities', name: 'Utilities', active: isPath('utilities') } ] } @@ -60,7 +62,7 @@ const externalLinks = [ ))} -
        +
        @@ -124,7 +126,11 @@ const externalLinks = [ } } - .container { - margin-top: 20px; + .my { + @include spacing(auto-default); + } + + .mb { + @include spacing(mb-default); } From 6658c96bafd4b8a0cc4b3409f3071a8a0f886747 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Fri, 2 Aug 2024 10:19:23 +0200 Subject: [PATCH 06/18] =?UTF-8?q?=F0=9F=92=84=20Match=20default=20font=20s?= =?UTF-8?q?ize=20with=20browser=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Accordion/accordion.module.scss | 3 +-- src/components/Alert/alert.module.scss | 4 ++-- src/components/Badge/badge.module.scss | 2 +- src/components/Button/button.module.scss | 2 +- src/components/Card/card.module.scss | 1 - src/components/Checkbox/checkbox.module.scss | 4 ++-- src/components/Input/input.module.scss | 4 ++-- src/components/Menu/menu.module.scss | 1 - src/components/Progress/progress.module.scss | 6 +++--- src/components/Radio/radio.module.scss | 3 +-- src/components/Rating/rating.module.scss | 2 +- src/components/Switch/switch.module.scss | 2 +- src/components/Table/table.module.scss | 2 +- src/components/Tabs/tabs.module.scss | 2 +- .../TimelineItem/timelineitem.module.scss | 5 ++--- src/pages/resets.astro | 1 + src/scss/config/typography.scss | 17 ++++++++--------- src/scss/global/tooltip.scss | 2 +- src/scss/resets.scss | 13 +++++++++---- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/components/Accordion/accordion.module.scss b/src/components/Accordion/accordion.module.scss index 7c4a957..af27342 100644 --- a/src/components/Accordion/accordion.module.scss +++ b/src/components/Accordion/accordion.module.scss @@ -7,7 +7,6 @@ li { @include border(primary-50, bottom); @include spacing(py-sm, px-none, m0); - @include typography(md); &:first-child { padding-top: 0; @@ -20,7 +19,7 @@ .title { @include layout(flex, h-between, v-center, sm); - @include typography(md, primary, left); + @include typography(default, primary, left); @include size('w100%'); @include spacing(p0); @include border(0); diff --git a/src/components/Alert/alert.module.scss b/src/components/Alert/alert.module.scss index b0a0ff4..4ce2155 100644 --- a/src/components/Alert/alert.module.scss +++ b/src/components/Alert/alert.module.scss @@ -41,11 +41,11 @@ } .title { - @include typography(hmd); + @include typography(lg, hmd); display: block; } .body { - @include typography(primary-20, md, hmd); + @include typography(primary-20, hmd); } } diff --git a/src/components/Badge/badge.module.scss b/src/components/Badge/badge.module.scss index d91e7bf..8f9358f 100644 --- a/src/components/Badge/badge.module.scss +++ b/src/components/Badge/badge.module.scss @@ -5,7 +5,7 @@ @include spacing(py-xs, px-sm); @include border-radius(xs); @include layout(inline-flex, v-center, xs); - @include typography(xs, primary-50); + @include typography(sm, primary-50); @include border(0); @include background(primary); diff --git a/src/components/Button/button.module.scss b/src/components/Button/button.module.scss index b08fd63..8967343 100644 --- a/src/components/Button/button.module.scss +++ b/src/components/Button/button.module.scss @@ -2,7 +2,7 @@ .button { @include layout(inline-flex, v-center, xs); - @include typography(md, primary-50, none); + @include typography(default, primary-50, none); @include spacing(py-sm, px-md); @include border-radius(xs); @include border(0); diff --git a/src/components/Card/card.module.scss b/src/components/Card/card.module.scss index d61aa8d..4b0736e 100644 --- a/src/components/Card/card.module.scss +++ b/src/components/Card/card.module.scss @@ -16,7 +16,6 @@ .title { @include spacing(p-default); @include border(primary-50, bottom); - @include typography(md); display: block; } diff --git a/src/components/Checkbox/checkbox.module.scss b/src/components/Checkbox/checkbox.module.scss index e2cd0a6..07da0c6 100644 --- a/src/components/Checkbox/checkbox.module.scss +++ b/src/components/Checkbox/checkbox.module.scss @@ -6,7 +6,7 @@ body { .checkbox { @include layout(inline-flex, sm); - @include typography(md, hmd); + @include typography(hmd); cursor: pointer; @@ -57,7 +57,7 @@ body { .text { @include spacing(ml-lg); - @include typography(sm, primary-20); + @include typography(md, primary-20); a { @include typography(primary-20); diff --git a/src/components/Input/input.module.scss b/src/components/Input/input.module.scss index 56b12c3..4650c69 100644 --- a/src/components/Input/input.module.scss +++ b/src/components/Input/input.module.scss @@ -54,7 +54,7 @@ @include layout(flex, column); .label { - @include typography(md, primary-20); + @include typography(primary-20); @include spacing(mb-xs); } @@ -73,7 +73,7 @@ } .subtext { - @include typography(sm, primary-30); + @include typography(md, primary-30); @include spacing(mt-xs); } } diff --git a/src/components/Menu/menu.module.scss b/src/components/Menu/menu.module.scss index 0eb53dd..4f36438 100644 --- a/src/components/Menu/menu.module.scss +++ b/src/components/Menu/menu.module.scss @@ -3,7 +3,6 @@ .menu { @include background(primary-70); @include spacing(p-md); - @include typography(md); @include border(bottom, primary-50); @include position(sticky, t0); @include layer(header); diff --git a/src/components/Progress/progress.module.scss b/src/components/Progress/progress.module.scss index 70a9848..7099b8f 100644 --- a/src/components/Progress/progress.module.scss +++ b/src/components/Progress/progress.module.scss @@ -11,19 +11,19 @@ body { @include size('w100%', h10px); @include border-radius(xl); @include visibility(hidden); - @include typography(bold, xxs); + @include typography(bold, xs); @include background(var(--w-progress-background)); color: var(--w-progress-background); &.medium { @include size(h15px); - @include typography(xs); + @include typography(sm); } &.large { @include size(h20px); - @include typography(sm); + @include typography(md); } &.square { diff --git a/src/components/Radio/radio.module.scss b/src/components/Radio/radio.module.scss index a022775..0bf5bc2 100644 --- a/src/components/Radio/radio.module.scss +++ b/src/components/Radio/radio.module.scss @@ -13,7 +13,6 @@ body { label { @include layout(flex, xs); - @include typography(md); cursor: pointer; @@ -71,7 +70,7 @@ body { .subtext { @include spacing(ml-lg); - @include typography(sm, primary-20); + @include typography(md, primary-20); a { @include typography(primary-20); diff --git a/src/components/Rating/rating.module.scss b/src/components/Rating/rating.module.scss index 24b4482..68dd408 100644 --- a/src/components/Rating/rating.module.scss +++ b/src/components/Rating/rating.module.scss @@ -35,7 +35,7 @@ body { .text { @include transition(color); - @include typography(md, primary-20); + @include typography(default, primary-20); @include spacing(ml-xs); &.m { diff --git a/src/components/Switch/switch.module.scss b/src/components/Switch/switch.module.scss index eceaf7d..7c7e4a3 100644 --- a/src/components/Switch/switch.module.scss +++ b/src/components/Switch/switch.module.scss @@ -36,7 +36,7 @@ body { } .label { - @include typography(sm); + @include typography(md); } } diff --git a/src/components/Table/table.module.scss b/src/components/Table/table.module.scss index afdd107..63e10b1 100644 --- a/src/components/Table/table.module.scss +++ b/src/components/Table/table.module.scss @@ -5,7 +5,7 @@ table { @include size('w100%'); - @include typography(md, left); + @include typography(left); border-collapse: collapse; } diff --git a/src/components/Tabs/tabs.module.scss b/src/components/Tabs/tabs.module.scss index 7a3f689..379d7d3 100644 --- a/src/components/Tabs/tabs.module.scss +++ b/src/components/Tabs/tabs.module.scss @@ -76,7 +76,7 @@ button { @include transition(color); @include background(transparent); - @include typography(md, primary-20); + @include typography(default, primary-20); @include border(0); @include spacing(p-md); @include layout(flex, v-center, sm); diff --git a/src/components/TimelineItem/timelineitem.module.scss b/src/components/TimelineItem/timelineitem.module.scss index 8726f8c..ed3e6bf 100644 --- a/src/components/TimelineItem/timelineitem.module.scss +++ b/src/components/TimelineItem/timelineitem.module.scss @@ -2,7 +2,6 @@ .item { @include position(relative); - @include typography(md); @include spacing(m0); &::before { @@ -10,7 +9,7 @@ @include size(25px); @include border-radius(max); @include background(var(--w-timeline-color)); - @include typography(sm); + @include typography(md); @include layout(inline-flex, center); @include border(2px, primary-70); @@ -21,7 +20,7 @@ } .title { - @include typography(bold, default); + @include typography(bold, lg); @include spacing(mb-sm); display: block; diff --git a/src/pages/resets.astro b/src/pages/resets.astro index add828d..a075f4a 100644 --- a/src/pages/resets.astro +++ b/src/pages/resets.astro @@ -31,6 +31,7 @@ import Card from '@components/Card/Card.astro'
      • Call the setup mixin in your global SCSS file.
      • +

        Start your dev server with:

        npm run dev
        diff --git a/src/scss/config/typography.scss b/src/scss/config/typography.scss index 6c8e4f6..712f000 100644 --- a/src/scss/config/typography.scss +++ b/src/scss/config/typography.scss @@ -4,15 +4,14 @@ $fontTypes: ( ) !default; $fontSizes: ( - 'xxs': 10px, - 'xs': 12px, - 'sm': 14px, - 'md': 16px, - 'default': 18px, - 'lg': 21px, - 'xl': 24px, - '2xl': 28px, - '3xl': 32px + 'xs': 10px, + 'sm': 12px, + 'md': 14px, + 'default': 16px, + 'lg': 18px, + 'xl': 21px, + '2xl': 24px, + '3xl': 28px ) !default; $lineHeights: ( diff --git a/src/scss/global/tooltip.scss b/src/scss/global/tooltip.scss index 6dd8536..0391aa8 100644 --- a/src/scss/global/tooltip.scss +++ b/src/scss/global/tooltip.scss @@ -24,7 +24,7 @@ &::before { @include border-radius(md); @include position(absolute); - @include typography(sm, hlg); + @include typography(md, hlg); @include background(var(--w-tooltip-background)); @include size(wmax-content); @include spacing(px-xs); diff --git a/src/scss/resets.scss b/src/scss/resets.scss index 4a4bf9b..db7e714 100644 --- a/src/scss/resets.scss +++ b/src/scss/resets.scss @@ -53,7 +53,7 @@ pre { @include border(primary-50); @include border-radius(md); - @include typography(sm); + @include typography(md); } code { @@ -73,7 +73,7 @@ } figcaption { - @include typography(sm, primary-20); + @include typography(md, primary-20); a { @include typography(primary-20); @@ -85,7 +85,7 @@ } p, ul, ol { - @include typography(md, hlg); + @include typography(hlg); @include spacing(my-default); } @@ -94,8 +94,13 @@ } blockquote { - @include typography(md); @include spacing(my-default, mx-none, pl-default); @include border(2px, left, primary-30); } + + hr { + @include size('w100%', h1px); + @include border(0); + @include background(primary-50); + } } From e6b8bebf5602a246bf68465ae6ef93cbd8e65ab1 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Fri, 2 Aug 2024 10:26:29 +0200 Subject: [PATCH 07/18] =?UTF-8?q?=E2=9C=A8=20Make=20Rating=20component=20a?= =?UTF-8?q?ccept=20decimal=20numbers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Rating/Rating.astro | 4 ++-- src/components/Rating/Rating.svelte | 4 ++-- src/components/Rating/Rating.tsx | 4 ++-- src/pages/rating.astro | 10 ++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/Rating/Rating.astro b/src/components/Rating/Rating.astro index 7a24fe9..851f9af 100644 --- a/src/components/Rating/Rating.astro +++ b/src/components/Rating/Rating.astro @@ -45,11 +45,11 @@ const translatedReviewText = reviewText.replace('{0}', `${reviewCount}`) {score > 0 && ( - {Array(score).fill('★').join('')} + {Array(Math.round(score)).fill('★').join('')} )} {showEmpty && ( - {Array(total - score).fill('★').join('')} + {Array(total - Math.round(score)).fill('★').join('')} )} {showText && ( diff --git a/src/components/Rating/Rating.svelte b/src/components/Rating/Rating.svelte index ae0433b..617bf2f 100644 --- a/src/components/Rating/Rating.svelte +++ b/src/components/Rating/Rating.svelte @@ -42,11 +42,11 @@ {#if score} - {Array(score).fill('★').join('')} + {Array(Math.round(score)).fill('★').join('')} {/if} {#if showEmpty} - {Array((total || 5) - score).fill('★').join('')} + {Array((total || 5) - Math.round(score)).fill('★').join('')} {/if} diff --git a/src/components/Rating/Rating.tsx b/src/components/Rating/Rating.tsx index 4c89ad2..ed1d5c2 100644 --- a/src/components/Rating/Rating.tsx +++ b/src/components/Rating/Rating.tsx @@ -43,12 +43,12 @@ const Rating = ({ {score > 0 && ( - {Array(score).fill('★').join('')} + {Array(Math.round(score)).fill('★').join('')} )} {showEmpty && ( - {Array(total - score).fill('★').join('')} + {Array(total - Math.round(score)).fill('★').join('')} )} {showText && ( diff --git a/src/pages/rating.astro b/src/pages/rating.astro index 9c65e28..2d0f332 100644 --- a/src/pages/rating.astro +++ b/src/pages/rating.astro @@ -148,6 +148,16 @@ const sections = getSections({
        + + + + ))} From b01962bd061a01ae58cf0f6a27e0e0588abbfa49 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Fri, 2 Aug 2024 11:58:23 +0200 Subject: [PATCH 08/18] =?UTF-8?q?=E2=9C=A8=20Add=20example=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Tabs/tabs.module.scss | 5 + src/pages/index.astro | 28 +-- src/static/Examples.astro | 268 +++++++++++++++++++++++++++ src/static/Layout.astro | 4 + 4 files changed, 292 insertions(+), 13 deletions(-) create mode 100644 src/static/Examples.astro diff --git a/src/components/Tabs/tabs.module.scss b/src/components/Tabs/tabs.module.scss index 379d7d3..cc61ee4 100644 --- a/src/components/Tabs/tabs.module.scss +++ b/src/components/Tabs/tabs.module.scss @@ -7,6 +7,7 @@ @include border-radius(md); @include spacing(p-xs); @include size(wmax-content); + @include border(0); button { @include transition(); @@ -46,6 +47,10 @@ &.outline .items button { @include border(bottom, 0); } + + &:not(.outline) .items { + @include border(0); + } .items { @include layout(column, xs); diff --git a/src/pages/index.astro b/src/pages/index.astro index 17519d5..178956d 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,5 +1,6 @@ --- import Layout from '@static/Layout.astro' +import Examples from '@static/Examples.astro' import CardWrapper from '@static/CardWrapper.astro' import Accordion from '@components/Accordion/Accordion.astro' @@ -66,7 +67,9 @@ const tabItems = [{ + +

        Components

        @@ -174,6 +177,9 @@ const tabItems = [{ diff --git a/src/static/Layout.astro b/src/static/Layout.astro index fbe14c9..80680d4 100644 --- a/src/static/Layout.astro +++ b/src/static/Layout.astro @@ -133,4 +133,8 @@ const externalLinks = [ .mb { @include spacing(mb-default); } + + .muted { + @include typography(primary-20, md); + } From e72a8ed1eef6a703f9b33c054ff1c3a4fecd7309 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Sat, 3 Aug 2024 20:20:31 +0200 Subject: [PATCH 09/18] =?UTF-8?q?=E2=99=BF=EF=B8=8F=20Improve=20components?= =?UTF-8?q?=20accessibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Menu/Menu.astro | 4 +-- src/components/Menu/Menu.svelte | 8 ++++-- src/components/Menu/Menu.tsx | 2 ++ .../ThemeSwitcher/ThemeSwitcher.astro | 1 + .../ThemeSwitcher/ThemeSwitcher.svelte | 3 ++- .../ThemeSwitcher/ThemeSwitcher.tsx | 3 ++- src/data.js | 26 +++++++++++++++---- src/pages/index.astro | 12 ++++++++- src/scss/global/theme.scss | 14 +++++----- src/static/Examples.astro | 16 +++++++++++- 10 files changed, 69 insertions(+), 20 deletions(-) diff --git a/src/components/Menu/Menu.astro b/src/components/Menu/Menu.astro index 208726a..a1ee360 100644 --- a/src/components/Menu/Menu.astro +++ b/src/components/Menu/Menu.astro @@ -45,7 +45,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has(' )} {!centerLogo && logo?.html && ( - + )} @@ -77,7 +77,7 @@ const wrapMenu = (logo?.url || logo?.html) && items?.length && Astro.slots.has(' )} {centerLogo && logo?.html && ( - + )} diff --git a/src/components/Menu/Menu.svelte b/src/components/Menu/Menu.svelte index 46bcb62..a9b2b56 100644 --- a/src/components/Menu/Menu.svelte +++ b/src/components/Menu/Menu.svelte @@ -43,7 +43,9 @@ {/if} {#if !centerLogo && logo?.html} - {@html logo.html} + + {@html logo.html} + {/if} {#if items?.length} @@ -73,7 +75,9 @@ {/if} {#if centerLogo && logo?.html} - {@html logo.html} + + {@html logo.html} + {/if} {#if logo?.url && centerLogo} diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index 5a0e78e..1077f9c 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -55,6 +55,7 @@ const Menu = ({ )} @@ -88,6 +89,7 @@ const Menu = ({ )} diff --git a/src/components/ThemeSwitcher/ThemeSwitcher.astro b/src/components/ThemeSwitcher/ThemeSwitcher.astro index 92f65a3..26a719b 100644 --- a/src/components/ThemeSwitcher/ThemeSwitcher.astro +++ b/src/components/ThemeSwitcher/ThemeSwitcher.astro @@ -38,6 +38,7 @@ const buttonClasses = [
        + + + + Connect your project to GitHub to start running automatic deployments. + + @@ -265,4 +274,9 @@ const tasks = [ display: block; } } + + .connect { + @include spacing(mt-sm); + @include typography(md); + } From 7de1a3787edc9af5ebe4393edf07bf7d736511d3 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Sun, 4 Aug 2024 23:06:05 +0200 Subject: [PATCH 10/18] =?UTF-8?q?=E2=9C=A8=20Add=20additional=20example=20?= =?UTF-8?q?themes=20+=20themes=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Button/button.module.scss | 2 +- src/data.js | 15 ++-- src/pages/themes.astro | 95 ++++++++++++++++++++++++ src/scss/global/theme.scss | 95 +++++++++++++++--------- src/static/Layout.astro | 14 ++-- src/utils/interpolate.ts | 23 ++++++ 6 files changed, 196 insertions(+), 48 deletions(-) create mode 100644 src/pages/themes.astro create mode 100644 src/utils/interpolate.ts diff --git a/src/components/Button/button.module.scss b/src/components/Button/button.module.scss index 8967343..cb25646 100644 --- a/src/components/Button/button.module.scss +++ b/src/components/Button/button.module.scss @@ -1,7 +1,7 @@ @use '../../scss/config.scss' as *; .button { - @include layout(inline-flex, v-center, xs); + @include layout(inline-flex, center, xs); @include typography(default, primary-50, none); @include spacing(py-sm, px-md); @include border-radius(xs); diff --git a/src/data.js b/src/data.js index 5ae2623..3139fdb 100644 --- a/src/data.js +++ b/src/data.js @@ -81,14 +81,15 @@ export const menuLogo = { } export const themes = { - '#252525': 'theme-dark', - '#DDD': 'theme-light', - '#415a77': 'theme-blue', - '#d5bdaf': 'theme-beige', - '#588157': 'theme-green' + '#252525': 'dark', + '#DDD': 'light', + '#415a77': 'midnight', + '#d5bdaf': 'vintage', + '#fCBA28': 'amber', + '#9D2BD6': 'synthwave', } export const toggleThemes = { - '#252525': 'theme-dark', - '#DDD': 'theme-light' + '#252525': 'dark', + '#DDD': 'light' } diff --git a/src/pages/themes.astro b/src/pages/themes.astro new file mode 100644 index 0000000..20ffcc4 --- /dev/null +++ b/src/pages/themes.astro @@ -0,0 +1,95 @@ +--- +import Layout from '@static/Layout.astro' +import Examples from '@static/Examples.astro' +import ThemeSwitcher from '@components/ThemeSwitcher/ThemeSwitcher.astro' +import Button from '@components/Button/Button.astro' +import Toast from '@components/Toast/Toast.astro' + +import { themes } from '@data' +--- + + +

        Themes

        + + + +
        + + +
        + + + + + Copied setup to clipboard + +
        + + + + diff --git a/src/scss/global/theme.scss b/src/scss/global/theme.scss index 0b3ffc1..098ac87 100644 --- a/src/scss/global/theme.scss +++ b/src/scss/global/theme.scss @@ -67,70 +67,97 @@ --w-color-primary-60: #101a2d; --w-color-primary-70: #061321; - --w-color-info: #1058b6; - --w-color-info-accent: #176ee0; - --w-color-info-fg: #FFF; - --w-color-success: #10ac95; + --w-color-info: #57a0ff; + --w-color-info-accent: #71afff; + --w-color-info-fg: #000; + --w-color-success: #10b59c; --w-color-success-accent: #1DD1A1; --w-color-success-fg: #000; --w-color-warning: #FF9F43; - --w-color-warning-accent: #f7AA61; + --w-color-warning-accent: #feb570; --w-color-warning-fg: #000; - --w-color-alert: #de3233; - --w-color-alert-accent: #EE5253; + --w-color-alert: #ed3b3c; + --w-color-alert-accent: #fb6161; --w-color-alert-fg: #FFF; } } - @if $theme == green { + @if $theme == 'vintage' { #{$selector} { --w-color-scheme: dark; - --w-color-primary: #FFF; - --w-color-primary-10: #EEE; - --w-color-primary-20: #b7ffe4; - --w-color-primary-30: #dad7cd; - --w-color-primary-40: #10AC84; - --w-color-primary-50: #4d6e4c; - --w-color-primary-60: #315037; - --w-color-primary-70: #22392d; + --w-color-primary: #000; + --w-color-primary-10: #111; + --w-color-primary-20: #6b4430; + --w-color-primary-30: #d6ccc2; + --w-color-primary-40: #cbb39a; + --w-color-primary-50: #e8d0b7; + --w-color-primary-60: #f5e6d5; + --w-color-primary-70: #f5ebe0; - --w-color-info: #0ABDE3; + --w-color-info: #6d95d1; --w-color-info-accent: #48DBFB; --w-color-info-fg: #000; - --w-color-success: #10AC84; + --w-color-success: #85c8ba; --w-color-success-accent: #1DD1A1; --w-color-success-fg: #000; - --w-color-warning: #FF9F43; + --w-color-warning: #e79d6b; --w-color-warning-accent: #f7AA61; --w-color-warning-fg: #000; - --w-color-alert: #de3233; + --w-color-alert: #bf6170; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; } } - @if $theme == beige { + @if $theme == 'amber' { #{$selector} { --w-color-scheme: dark; - --w-color-primary: #000; - --w-color-primary-10: #111; - --w-color-primary-20: #97725c; - --w-color-primary-30: #d6ccc2; - --w-color-primary-40: #e3d5ca; - --w-color-primary-50: #ecddcd; - --w-color-primary-60: #f1e6da; - --w-color-primary-70: #f5ebe0; + --w-color-primary: #FFF; + --w-color-primary-10: #DDD; + --w-color-primary-20: #FFF3DB; + --w-color-primary-30: #757575; + --w-color-primary-40: #232323; + --w-color-primary-50: #312e31; + --w-color-primary-60: #222; + --w-color-primary-70: #111; - --w-color-info: #0ABDE3; + --w-color-info: #78dcdc; --w-color-info-accent: #48DBFB; --w-color-info-fg: #000; - --w-color-success: #10AC84; - --w-color-success-accent: #1DD1A1; + --w-color-success: #a9dc62; + --w-color-success-accent: #97da3b; --w-color-success-fg: #000; - --w-color-warning: #FF9F43; + --w-color-warning: #FCBA28; --w-color-warning-accent: #f7AA61; --w-color-warning-fg: #000; - --w-color-alert: #de3233; + --w-color-alert: #ff6188; + --w-color-alert-accent: #EE5253; + --w-color-alert-fg: #000; + } + } + + @if $theme == 'synthwave' { + #{$selector} { + --w-color-scheme: dark; + --w-color-primary: #FFF; + --w-color-primary-10: #EEE; + --w-color-primary-20: #fad1ba; + --w-color-primary-30: #a8b6de; + --w-color-primary-40: #8212ba; + --w-color-primary-50: #9D2BD6; + --w-color-primary-60: #0f1b33; + --w-color-primary-70: #030d1e; + + --w-color-info: #1c98ff; + --w-color-info-accent: #6be4ff; + --w-color-info-fg: #000; + --w-color-success: #83e300; + --w-color-success-accent: #b7ff51; + --w-color-success-fg: #000; + --w-color-warning: #FF9F43; + --w-color-warning-accent: #ffb672; + --w-color-warning-fg: #000; + --w-color-alert: #ff3333; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; } diff --git a/src/static/Layout.astro b/src/static/Layout.astro index 80680d4..2682b69 100644 --- a/src/static/Layout.astro +++ b/src/static/Layout.astro @@ -9,7 +9,7 @@ const menuClasses = [ nonStickyMenu && 'fixed' ].filter(Boolean).join(' ') -const theme = (Astro.cookies.get('w-theme')?.value || 'theme-dark') as string +const theme = (Astro.cookies.get('w-theme')?.value || 'dark') as string const isPath = (path: string) => Astro.url.pathname.includes(path) const menu = { @@ -19,6 +19,7 @@ const menu = { items: [ { url: '/svelte', name: 'Svelte', active: isPath('svelte') }, { url: '/react', name: 'React', active: isPath('react') }, + { url: '/themes', name: 'Themes', active: isPath('themes') }, { url: '/resets', name: 'Resets', active: isPath('resets') }, { url: '/utilities', name: 'Utilities', active: isPath('utilities') } ] @@ -76,11 +77,12 @@ const externalLinks = [ fontRegular: '/fonts/Inter-Regular.woff2', fontBold: '/fonts/Inter-Bold.woff2', themes: ( - dark: '.theme-dark', - light: '.theme-light', - midnight: '.theme-blue', - green: '.theme-green', - beige: '.theme-beige' + dark: '.dark', + light: '.light', + midnight: '.midnight', + vintage: '.vintage', + amber: '.amber', + synthwave: '.synthwave', ) )); diff --git a/src/utils/interpolate.ts b/src/utils/interpolate.ts new file mode 100644 index 0000000..d87c696 --- /dev/null +++ b/src/utils/interpolate.ts @@ -0,0 +1,23 @@ +export const clamp = ( + num: number, + min: number, + max: number +) => Math.min(Math.max(num, min), max) + +export const lerp = ( + x: number, + y: number, + z: number +) => x * (1 - z) + y * z + +export const invlerp = ( + x: number, + y: number, + z: number +) => clamp((z - x) / (y - x), 0, 1) + +export const interpolate = ( + value: number, + input: [x: number, y: number], + output: [x: number, y: number], +) => lerp(output[0], output[1], invlerp(input[0], input[1], value)) From 633d4f742465d70bc67114e66ce6c6cbbf20b035 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Mon, 5 Aug 2024 13:04:43 +0200 Subject: [PATCH 11/18] =?UTF-8?q?=E2=9C=A8=20Add=20Modal=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 22 +++ src/components/Button/button.ts | 2 +- src/components/Icon/map.ts | 2 + src/components/Modal/Modal.astro | 50 +++++++ src/components/Modal/Modal.svelte | 52 +++++++ src/components/Modal/Modal.tsx | 55 +++++++ src/components/Modal/modal.module.scss | 67 +++++++++ src/components/Modal/modal.ts | 13 ++ src/icons/close.svg | 3 + src/pages/index.astro | 3 + src/pages/modal.astro | 197 +++++++++++++++++++++++++ src/scss/config/color-palette.scss | 1 + src/scss/global/theme.scss | 6 + src/static/ComponentWrapper.astro | 6 +- src/utils/modal.ts | 60 ++++++++ 15 files changed, 535 insertions(+), 4 deletions(-) create mode 100644 src/components/Modal/Modal.astro create mode 100644 src/components/Modal/Modal.svelte create mode 100644 src/components/Modal/Modal.tsx create mode 100644 src/components/Modal/modal.module.scss create mode 100644 src/components/Modal/modal.ts create mode 100644 src/icons/close.svg create mode 100644 src/pages/modal.astro create mode 100644 src/utils/modal.ts diff --git a/README.md b/README.md index 9cc6998..e371980 100644 --- a/README.md +++ b/README.md @@ -107,30 +107,51 @@ Default component styles can be changed by overriding the following CSS variable ```scss html body { + // Avatar component --w-avatar-border: var(--w-color-primary-70); + + // Checkbox component --w-checkbox-color: var(--w-color-primary); + + // Progress component --w-progress-color: var(--w-color-primary); --w-progress-background: var(--w-color-primary-50); --w-progress-stripe-light: var(--w-color-primary); --w-progress-stripe-dark: var(--w-color-primary-10); + + // Radio component --w-radio-color: var(--w-color-primary); + + // Rating component --w-rating-color: var(--w-color-primary); --w-rating-empty-color: var(--w-color-primary); --w-rating-empty-background: var(--w-color-primary-70); --w-rating-size: 18px; + + // Scrollbars --w-scrollbar-bg: var(--w-color-primary-60); --w-scrollbar-fg: var(--w-color-primary-50); + + // Spinner component --w-spinner-color: var(--w-color-primary); --w-spinner-width: 2px; --w-spinner-speed: 2s; --w-spinner-size: 30px; --w-spinner-dash: 8; + + // Switch component --w-switch-off-color: var(--w-color-primary-50); --w-switch-on-color: var(--w-color-primary); + + // ThemeSwitcher component --w-theme-switcher-size: 20px; + + // Timeline component --w-timeline-color: var(--w-color-primary-50); --w-timeline-text-color: var(--w-color-primary); --w-timeline-counter: decimal; + + // Tooltips --w-tooltip-background: var(--w-color-primary); --w-tooltip-color: var(--w-color-primary-70); @@ -175,6 +196,7 @@ import { Accordion } from 'webcoreui/react' - [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon) - [Input](https://github.com/Frontendland/webcoreui/tree/main/src/components/Input) - [Menu](https://github.com/Frontendland/webcoreui/tree/main/src/components/Menu) +- [Modal](https://github.com/Frontendland/webcoreui/tree/main/src/components/Modal) - [Progress](https://github.com/Frontendland/webcoreui/tree/main/src/components/Progress) - [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio) - [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating) diff --git a/src/components/Button/button.ts b/src/components/Button/button.ts index b68ffb3..a3dda08 100644 --- a/src/components/Button/button.ts +++ b/src/components/Button/button.ts @@ -18,5 +18,5 @@ export type SvelteButtonProps = { export type ReactButtonProps = { onClick?: () => any - children: React.ReactNode + children?: React.ReactNode } & ButtonProps diff --git a/src/components/Icon/map.ts b/src/components/Icon/map.ts index 661ebe0..1906853 100644 --- a/src/components/Icon/map.ts +++ b/src/components/Icon/map.ts @@ -2,6 +2,7 @@ import Alert from '../../icons/alert.svg?raw' import ArrowDown from '../../icons/arrow-down.svg?raw' import Check from '../../icons/check.svg?raw' import CircleCheck from '../../icons/circle-check.svg?raw' +import Close from '../../icons/close.svg?raw' import Github from '../../icons/github.svg?raw' import Info from '../../icons/info.svg?raw' import Moon from '../../icons/moon.svg?raw' @@ -13,6 +14,7 @@ const iconMap = { 'arrow-down': ArrowDown, 'check': Check, 'circle-check': CircleCheck, + 'close': Close, 'github': Github, 'info': Info, 'moon': Moon, diff --git a/src/components/Modal/Modal.astro b/src/components/Modal/Modal.astro new file mode 100644 index 0000000..e79dd4a --- /dev/null +++ b/src/components/Modal/Modal.astro @@ -0,0 +1,50 @@ +--- +import type { ModalProps } from './modal' +import styles from './modal.module.scss' + +import Button from '../Button/Button.astro' +import closeIcon from '../../icons/close.svg?raw' + +interface Props extends ModalProps {} + +const { + title, + subTitle, + showCloseIcon = true, + closeOnEsc = true, + closeOnOverlay = true, + id, + className +} = Astro.props + +const close = [ + showCloseIcon && 'icon', + closeOnEsc && 'esc', + closeOnOverlay && 'overlay' +].filter(Boolean).join(',') + +const classes = [ + styles.modal, + className +] +--- + + + {showCloseIcon && ( + + )} + {title && {title}} + {subTitle &&
        {subTitle}
        } + +
        +
        diff --git a/src/components/Modal/Modal.svelte b/src/components/Modal/Modal.svelte new file mode 100644 index 0000000..194d83c --- /dev/null +++ b/src/components/Modal/Modal.svelte @@ -0,0 +1,52 @@ + + + + {#if showCloseIcon} + + {/if} + {#if title} + {title} + {/if} + {#if subTitle} +
        {subTitle}
        + {/if} + +
        +
        diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx new file mode 100644 index 0000000..297f443 --- /dev/null +++ b/src/components/Modal/Modal.tsx @@ -0,0 +1,55 @@ +import React from 'react' +import type { ReactModalProps } from './modal' + +import styles from './modal.module.scss' +import { classNames } from '../../utils/classNames' + +import Button from '../Button/Button.tsx' +import closeIcon from '../../icons/close.svg?raw' + +const Modal = ({ + title, + subTitle, + showCloseIcon = true, + closeOnEsc = true, + closeOnOverlay = true, + id, + className, + children +}: ReactModalProps) => { + const classes = classNames([ + styles.modal, + className + ]) + + const close = [ + showCloseIcon && 'icon', + closeOnEsc && 'esc', + closeOnOverlay && 'overlay' + ].filter(Boolean).join(',') + + return ( + + + {showCloseIcon && ( + +
        + + ) +} + +export default Modal diff --git a/src/components/Modal/modal.module.scss b/src/components/Modal/modal.module.scss new file mode 100644 index 0000000..0170686 --- /dev/null +++ b/src/components/Modal/modal.module.scss @@ -0,0 +1,67 @@ +@import '../../scss/config.scss'; + +.modal { + @include transition(); + @include position(fixed, 't50%', 'l50%'); + @include spacing(0, p-default); + @include layer(modal); + @include visibility(block, 0); + @include border(primary-50); + @include background(primary-70); + @include typography(primary); + @include border-radius(md); + @include size('w90%'); + + transform: translate(-50%, calc(-50% + 15px)); + max-width: 500px; + pointer-events: none; + + &[data-show="true"] { + @include visibility(1); + + transform: translate(-50%, -50%); + pointer-events: all; + + + .overlay { + @include visibility(1); + pointer-events: all; + } + } + + .close { + @include position(absolute, t10px, r10px); + @include spacing(p-xs); + + svg { + @include size(10px); + } + } + + .title { + @include typography(lg); + @include spacing(mb-xs); + display: block; + } + + .subTitle { + @include typography(primary-20); + @include spacing(mb-xs); + } +} + +.overlay { + @include transition(opacity); + @include position(fixed); + @include background(overlay); + @include layer(header); + @include visibility(0); + + inset: 0; + pointer-events: none; +} + +@include media(xs) { + .modal { + @include size('wauto'); + } +} diff --git a/src/components/Modal/modal.ts b/src/components/Modal/modal.ts new file mode 100644 index 0000000..59bbec6 --- /dev/null +++ b/src/components/Modal/modal.ts @@ -0,0 +1,13 @@ +export type ModalProps = { + title?: string + subTitle?: string + showCloseIcon?: boolean + closeOnEsc?: boolean + closeOnOverlay?: boolean + id?: string + className?: string +} + +export type ReactModalProps = { + children?: React.ReactNode +} & ModalProps diff --git a/src/icons/close.svg b/src/icons/close.svg new file mode 100644 index 0000000..88d02d9 --- /dev/null +++ b/src/icons/close.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 2650672..8128531 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -137,6 +137,9 @@ const tabItems = [{ + + + diff --git a/src/pages/modal.astro b/src/pages/modal.astro new file mode 100644 index 0000000..a273eb4 --- /dev/null +++ b/src/pages/modal.astro @@ -0,0 +1,197 @@ +--- +import Layout from '@static/Layout.astro' +import ComponentWrapper from '@static/ComponentWrapper.astro' + +import Button from '@components/Button/Button.astro' +import AstroModal from '@components/Modal/Modal.astro' +import SvelteModal from '@components/Modal/Modal.svelte' +import ReactModal from '@components/Modal/Modal.tsx' + +import { getSections } from '@helpers' + +const sections = getSections({ + title: 'modals', + components: [AstroModal, SvelteModal, ReactModal] +}) +--- + + +

        Modal

        +
        + + + + +

        + Click on the close icon, close button, overlay, or hit esc to close this modal. +

        + + +
        +
        + + + + + +

        + Click on the close icon, close button, overlay, or hit esc to close this modal. +

        + + +
        +
        + + + + + +

        + Click on the close icon, close button, overlay, or hit esc to close this modal. +

        + + +
        +
        +
        + + {sections.map((section, index) => ( +

        {section.title}

        +
        + + + + Modal with content only + + + + + + + Modal with a title + + + + + + + Modal with title and sub title + + + + + + + This modal cannot be closed by clicking the esc button. + + + + + + + This modal cannot be closed by clicking the overlay. + + + + + + + This modal doesn't have a close button. It can only be closed by clicking on the overlay or using the esc button. + + +
        + ))} +
        + + diff --git a/src/scss/config/color-palette.scss b/src/scss/config/color-palette.scss index f2b19fa..522b297 100644 --- a/src/scss/config/color-palette.scss +++ b/src/scss/config/color-palette.scss @@ -20,4 +20,5 @@ $colorPalette: ( 'alert': var(--w-color-alert), 'alert-accent': var(--w-color-alert-accent), 'alert-fg': var(--w-color-alert-fg), + 'overlay': var(--w-color-overlay) ) !default; diff --git a/src/scss/global/theme.scss b/src/scss/global/theme.scss index 098ac87..d921be7 100644 --- a/src/scss/global/theme.scss +++ b/src/scss/global/theme.scss @@ -25,6 +25,7 @@ --w-color-alert: #de3233; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; + --w-color-overlay: #0000009e; } } @@ -52,6 +53,7 @@ --w-color-alert: #de3233; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; + --w-color-overlay: #0000009e; } } @@ -79,6 +81,7 @@ --w-color-alert: #ed3b3c; --w-color-alert-accent: #fb6161; --w-color-alert-fg: #FFF; + --w-color-overlay: #0000009e; } } @@ -106,6 +109,7 @@ --w-color-alert: #bf6170; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; + --w-color-overlay: #0000009e; } } @@ -133,6 +137,7 @@ --w-color-alert: #ff6188; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #000; + --w-color-overlay: #0000009e; } } @@ -160,6 +165,7 @@ --w-color-alert: #ff3333; --w-color-alert-accent: #EE5253; --w-color-alert-fg: #FFF; + --w-color-overlay: #0000009e; } } } diff --git a/src/static/ComponentWrapper.astro b/src/static/ComponentWrapper.astro index 807a419..30fae26 100644 --- a/src/static/ComponentWrapper.astro +++ b/src/static/ComponentWrapper.astro @@ -18,7 +18,7 @@ const { diff --git a/src/utils/modal.ts b/src/utils/modal.ts new file mode 100644 index 0000000..d5aeb10 --- /dev/null +++ b/src/utils/modal.ts @@ -0,0 +1,60 @@ +export const modal = (element: string) => { + const htmlElement = document.querySelector(element) as HTMLElement + + if (htmlElement) { + const handleClose = { + icon: () => { + const close = htmlElement.querySelector('[data-id="close"]') + + const listener = () => { + htmlElement.dataset.show = '' + + close?.removeEventListener('click', listener) + } + + close?.addEventListener('click', listener) + }, + + esc: () => { + const listener = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + htmlElement.dataset.show = '' + + document.removeEventListener('keydown', listener) + } + } + + document.addEventListener('keydown', listener) + }, + + overlay: () => { + const close = htmlElement.nextElementSibling + + const listener = () => { + htmlElement.dataset.show = '' + + close?.removeEventListener('click', listener) + } + + close?.addEventListener('click', listener) + } + } + + const closeOptions = htmlElement.dataset.close?.split(',') + + htmlElement.dataset.show = 'true' + + closeOptions?.forEach(option => { + handleClose[option as keyof typeof handleClose]() + }) + } +} + + +export const closeModal = (element: string) => { + const htmlElement = document.querySelector(element) as HTMLElement + + if (htmlElement) { + htmlElement.dataset.show = '' + } +} From 39f9bf8de305ba6ebbd09c13099e1b8532a738c3 Mon Sep 17 00:00:00 2001 From: Frontendland Date: Tue, 6 Aug 2024 09:13:57 +0200 Subject: [PATCH 12/18] =?UTF-8?q?=E2=9C=A8=20Add=20Slider=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + scripts/buildTypes.js | 3 +- src/components/Slider/Slider.astro | 42 +++++++++ src/components/Slider/Slider.svelte | 40 +++++++++ src/components/Slider/Slider.tsx | 46 ++++++++++ src/components/Slider/slider.module.scss | 48 +++++++++++ src/components/Slider/slider.ts | 19 ++++ src/pages/index.astro | 4 + src/pages/slider.astro | 105 +++++++++++++++++++++++ src/pages/themes.astro | 12 +-- src/playground/ReactPlayground.tsx | 13 +++ src/playground/SveltePlayground.svelte | 13 +++ src/playground/playground.module.scss | 4 + src/scss/global/theme.scss | 8 +- 14 files changed, 348 insertions(+), 10 deletions(-) create mode 100644 src/components/Slider/Slider.astro create mode 100644 src/components/Slider/Slider.svelte create mode 100644 src/components/Slider/Slider.tsx create mode 100644 src/components/Slider/slider.module.scss create mode 100644 src/components/Slider/slider.ts create mode 100644 src/pages/slider.astro diff --git a/README.md b/README.md index e371980..b09fde6 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ import { Accordion } from 'webcoreui/react' - [Progress](https://github.com/Frontendland/webcoreui/tree/main/src/components/Progress) - [Radio](https://github.com/Frontendland/webcoreui/tree/main/src/components/Radio) - [Rating](https://github.com/Frontendland/webcoreui/tree/main/src/components/Rating) +- [Slider](https://github.com/Frontendland/webcoreui/tree/main/src/components/Slider) - [Spinner](https://github.com/Frontendland/webcoreui/tree/main/src/components/Spinner) - [Switch](https://github.com/Frontendland/webcoreui/tree/main/src/components/Switch) - [Table](https://github.com/Frontendland/webcoreui/tree/main/src/components/Table) diff --git a/scripts/buildTypes.js b/scripts/buildTypes.js index 7378210..75eb0b2 100644 --- a/scripts/buildTypes.js +++ b/scripts/buildTypes.js @@ -27,7 +27,8 @@ const buildTypes = type => { 'Checkbox', 'Input', 'Radio', - 'Switch' + 'Switch', + 'Slider' ] return componentsWithSvelteSpecificTypes.includes(component) diff --git a/src/components/Slider/Slider.astro b/src/components/Slider/Slider.astro new file mode 100644 index 0000000..d7f2296 --- /dev/null +++ b/src/components/Slider/Slider.astro @@ -0,0 +1,42 @@ +--- +import type { SliderProps } from './slider' + +import styles from './slider.module.scss' +import { classNames } from '../../utils/classNames' + +interface Props extends SliderProps {} + +const { + min, + max, + value, + step, + color, + background, + thumb, + id, + className +} = Astro.props + +const classes = [ + styles.slider, + className +] + +const styleVariables = classNames([ + color && `--w-slider-color: ${color};`, + background && `--w-slider-background: ${background};`, + thumb && `--w-slider-thumb: ${thumb};` +]) +--- + + diff --git a/src/components/Slider/Slider.svelte b/src/components/Slider/Slider.svelte new file mode 100644 index 0000000..29a1b8f --- /dev/null +++ b/src/components/Slider/Slider.svelte @@ -0,0 +1,40 @@ + + + diff --git a/src/components/Slider/Slider.tsx b/src/components/Slider/Slider.tsx new file mode 100644 index 0000000..d310201 --- /dev/null +++ b/src/components/Slider/Slider.tsx @@ -0,0 +1,46 @@ +import React from 'react' +import type { ReactSliderProps } from './slider' + +import styles from './slider.module.scss' +import { classNames } from '../../utils/classNames' + +const Slider = ({ + min, + max, + value, + step, + color, + background, + thumb, + id, + className, + onChange +}: ReactSliderProps) => { + const classes = classNames([ + styles.slider, + className + ]) + + const styleVariables = { + ...(color && { '--w-slider-color': color }), + ...(background && { '--w-slider-background': background }), + ...(thumb && { '--w-slider-thumb': thumb }) + } as React.CSSProperties + + return ( + + + ) +} + +export default Slider diff --git a/src/components/Slider/slider.module.scss b/src/components/Slider/slider.module.scss new file mode 100644 index 0000000..f2b209b --- /dev/null +++ b/src/components/Slider/slider.module.scss @@ -0,0 +1,48 @@ +@import '../../scss/config.scss'; + +body { + --w-slider-background: var(--w-color-primary-50); + --w-slider-color: var(--w-color-primary); + --w-slider-thumb: var(--w-color-primary-50); +} + +.slider { + @include border-radius(xl); + @include size('w100%'); + @include visibility(hidden); + @include size(h10px); + @include spacing(m0); + + -webkit-appearance: none; + appearance: none; + cursor: pointer; +} + +.slider::-webkit-slider-runnable-track { + @include background(var(--w-slider-background)); +} + +.slider::-moz-range-track { + @include background(var(--w-slider-background)); + @include size(h10px); +} + +.slider::-webkit-slider-thumb { + @include background(var(--w-slider-thumb)); + @include size(10px); + @include border-radius(max); + @include border(var(--w-slider-color)); + + -webkit-appearance: none; + appearance: none; + box-shadow: -405px 0 0 400px var(--w-slider-color); +} + +.slider::-moz-range-thumb { + @include background(var(--w-slider-thumb)); + @include size(9px); + @include border-radius(max); + @include border(var(--w-slider-color)); + + box-shadow: -405px 0 0 400px var(--w-slider-color); +} diff --git a/src/components/Slider/slider.ts b/src/components/Slider/slider.ts new file mode 100644 index 0000000..c617439 --- /dev/null +++ b/src/components/Slider/slider.ts @@ -0,0 +1,19 @@ +export type SliderProps = { + min: number + max: number + value?: number + step?: number + id?: string + color?: string + background?: string + thumb?: string + className?: string +} + +export type SvelteSliderProps = { + onChange?: (e: any) => any +} & SliderProps + +export type ReactSliderProps = { + onChange?: (e: any) => any +} & SliderProps diff --git a/src/pages/index.astro b/src/pages/index.astro index 8128531..7f17d3c 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -15,6 +15,7 @@ import Menu from '@components/Menu/Menu.astro' import Progress from '@components/Progress/Progress.astro' import Radio from '@components/Radio/Radio.astro' import Rating from '@components/Rating/Rating.astro' +import Slider from '@components/Slider/Slider.astro' import Spinner from '@components/Spinner/Spinner.astro' import Switch from '@components/Switch/Switch.astro' import Table from '@components/Table/Table.astro' @@ -152,6 +153,9 @@ const tabItems = [{ + + + diff --git a/src/pages/slider.astro b/src/pages/slider.astro new file mode 100644 index 0000000..05691ff --- /dev/null +++ b/src/pages/slider.astro @@ -0,0 +1,105 @@ +--- +import Layout from '@static/Layout.astro' +import ComponentWrapper from '@static/ComponentWrapper.astro' + +import AstroSlider from '@components/Slider/Slider.astro' +import SvelteSlider from '@components/Slider/Slider.svelte' +import ReactSlider from '@components/Slider/Slider.tsx' + +import { getSections } from '@helpers' + +const sections = getSections({ + title: 'sliders', + components: [AstroSlider, SvelteSlider, ReactSlider], + showSubTitle: true +}) +--- + + +

        Slider

        +
        + + + + + + + + + + + +
        + + {sections.map(section => ( +

        {section.title}

        + + {section.subTitle &&

        } + +
        + + + + + + + + + + + + + + + + + +
        + + 20 +
        +
        + + + 40 + + +
        + ))} + + + diff --git a/src/pages/themes.astro b/src/pages/themes.astro index 20ffcc4..e8ec20a 100644 --- a/src/pages/themes.astro +++ b/src/pages/themes.astro @@ -4,6 +4,7 @@ import Examples from '@static/Examples.astro' import ThemeSwitcher from '@components/ThemeSwitcher/ThemeSwitcher.astro' import Button from '@components/Button/Button.astro' import Toast from '@components/Toast/Toast.astro' +import Slider from '@components/Slider/Slider.astro' import { themes } from '@data' --- @@ -15,9 +16,8 @@ import { themes } from '@data'
        +