From eaef5d0d1a5e73fb45782cebab78dad499ff56ef Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Fri, 19 Apr 2024 10:49:05 -0700 Subject: [PATCH 01/70] progress check --- .nvmrc | 1 + .prettierrc.json | 18 ++++++ package-lock.json | 15 +++-- package.json | 4 +- src/components/box/CdrBox.vue | 59 +++++++++++++++++++ src/components/box/examples/Box.vue | 57 ++++++++++++++++++ src/components/box/stylesMap.mts | 50 ++++++++++++++++ src/components/examples.js | 4 ++ .../styledButton/CdrStyledButton.vue | 34 +++++++++++ .../styledButton/examples/StyledButton.vue | 47 +++++++++++++++ .../styles/CdrUnstyledButton.module.scss | 6 ++ .../styles/vars/CdrUnstyledButton.vars.scss | 17 ++++++ .../unstyledButton/CdrUnstyledButton.vue | 37 ++++++++++++ .../examples/UnstyledButton.vue | 47 +++++++++++++++ .../styles/CdrStyledButton.module.scss | 6 ++ .../styles/vars/CdrStyledButton.vars.scss | 17 ++++++ src/dev/DevPage.vue | 3 - src/dev/index.js | 2 +- src/dev/router.js | 2 + src/lib.ts | 3 +- src/types/other.ts | 46 +++++++++++++++ src/types/symbols.ts | 1 - 22 files changed, 460 insertions(+), 16 deletions(-) create mode 100644 .nvmrc create mode 100644 .prettierrc.json create mode 100644 src/components/box/CdrBox.vue create mode 100644 src/components/box/examples/Box.vue create mode 100644 src/components/box/stylesMap.mts create mode 100644 src/components/styledButton/CdrStyledButton.vue create mode 100644 src/components/styledButton/examples/StyledButton.vue create mode 100644 src/components/styledButton/styles/CdrUnstyledButton.module.scss create mode 100644 src/components/styledButton/styles/vars/CdrUnstyledButton.vars.scss create mode 100644 src/components/unstyledButton/CdrUnstyledButton.vue create mode 100644 src/components/unstyledButton/examples/UnstyledButton.vue create mode 100644 src/components/unstyledButton/styles/CdrStyledButton.module.scss create mode 100644 src/components/unstyledButton/styles/vars/CdrStyledButton.vars.scss create mode 100644 src/types/other.ts diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..2edeafb09 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..51878cea5 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,18 @@ +{ + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "trailingComma": "all", + "bracketSpacing": true, + "bracketSameLine": false, + "arrowParens": "always", + "proseWrap": "preserve", + "htmlWhitespaceSensitivity": "ignore", + "vueIndentScriptAndStyle": false, + "endOfLine": "auto", + "singleAttributePerLine": true +} diff --git a/package-lock.json b/package-lock.json index 8bafaa9a0..4fd5cdab0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "chromedriver": "^122", "concat": "^1.0.3", "cross-env": "^7.0.3", + "csstype": "^3.1.3", "cz-conventional-changelog": "^3.3.0", "eslint": "^8.42.0", "eslint-config-prettier": "^8.8.0", @@ -5778,10 +5779,9 @@ "dev": true }, "node_modules/csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "peer": true + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/cz-conventional-changelog": { "version": "3.3.0", @@ -18789,10 +18789,9 @@ } }, "csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "peer": true + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "cz-conventional-changelog": { "version": "3.3.0", diff --git a/package.json b/package.json index 8d3e28328..ba46879b1 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,8 @@ "build:docgen": "node docgen.mjs", "build:extractcss": "node build/extract-css.js", "build:variables": "node build/component-variables-transfer.js", - "build:icons": "ts-node src/components/icon/build/generate.ts" + "build:icons": "ts-node src/components/icon/build/generate.ts", + "type-check": "vue-tsc --noEmit" }, "devDependencies": { "@babel/preset-env": "^7.18.2", @@ -72,6 +73,7 @@ "chromedriver": "^122", "concat": "^1.0.3", "cross-env": "^7.0.3", + "csstype": "^3.1.3", "cz-conventional-changelog": "^3.3.0", "eslint": "^8.42.0", "eslint-config-prettier": "^8.8.0", diff --git a/src/components/box/CdrBox.vue b/src/components/box/CdrBox.vue new file mode 100644 index 000000000..313842f93 --- /dev/null +++ b/src/components/box/CdrBox.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/components/box/examples/Box.vue b/src/components/box/examples/Box.vue new file mode 100644 index 000000000..4921249c4 --- /dev/null +++ b/src/components/box/examples/Box.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/components/box/stylesMap.mts b/src/components/box/stylesMap.mts new file mode 100644 index 000000000..f97c97ef9 --- /dev/null +++ b/src/components/box/stylesMap.mts @@ -0,0 +1,50 @@ +import type { SpacingKey, DirectKey, StylingKey } from '../../types/other'; + +const spacing: Record = { + m: 'margin', + mx: 'marginInline', + my: 'marginBlock', + p: 'padding', + px: 'paddingInline', + py: 'paddingBlock', +}; + +interface StylesMapValue { + property: string; + converter?: Function; +} + +const stylesMap: Partial> = {}; + +// Add spacing +(Object.keys(spacing) as Array).forEach((key) => { + stylesMap[key] = { + property: spacing[key], + converter: (value: string) => `var(--cdr-space-${value})`, + }; +}); + +// Add any CSS properties that do not use different names than their prop name +(['display'] as Array).forEach((key) => { + stylesMap[key] = { property: key }; +}); + +// Add radius +stylesMap.radius = { + property: 'borderRadius', + converter: (value: string) => `var(--cdr-radius-${value})`, +}; + +// Add background +stylesMap.background = { + property: 'backgroundColor', + converter: (value: string) => `var(--cdr-color-background-${value})`, +}; + +// Add shadow +stylesMap.shadow = { + property: 'boxShadow', + converter: (value: string) => `var(--cdr-prominence-${value})`, +}; + +export default stylesMap; diff --git a/src/components/examples.js b/src/components/examples.js index 670aaa351..f1a2fa3e4 100644 --- a/src/components/examples.js +++ b/src/components/examples.js @@ -1,6 +1,7 @@ import abstract from 'componentsdir/abstract/examples/Abstract.vue'; import accordion from 'componentsdir/accordion/examples/Accordion.vue'; import banner from 'componentsdir/banner/examples/Banner.vue'; +import box from 'componentsdir/box/examples/Box.vue'; import breadcrumb from 'componentsdir/breadcrumb/examples/Breadcrumb.vue'; import buttons from 'componentsdir/button/examples/Buttons.vue'; import captions from 'componentsdir/caption/examples/Caption.vue'; @@ -37,11 +38,13 @@ import toast from 'componentsdir/toast/examples/Toast.vue'; import toggleButton from 'componentsdir/toggleButton/examples/ToggleButton.vue'; import cdrSwitch from 'componentsdir/switch/examples/Switch.vue'; // Can't name it switch because it's a JS keyword import tooltip from 'componentsdir/tooltip/examples/Tooltip.vue'; +import unstyledButton from 'componentsdir/unstyledButton/examples/UnstyledButton.vue'; export default { abstract, banner, accordion, + box, breadcrumb, buttons, captions, @@ -78,4 +81,5 @@ export default { toggleButton, cdrSwitch, tooltip, + unstyledButton, }; diff --git a/src/components/styledButton/CdrStyledButton.vue b/src/components/styledButton/CdrStyledButton.vue new file mode 100644 index 000000000..449f98871 --- /dev/null +++ b/src/components/styledButton/CdrStyledButton.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/src/components/styledButton/examples/StyledButton.vue b/src/components/styledButton/examples/StyledButton.vue new file mode 100644 index 000000000..3aefa46a0 --- /dev/null +++ b/src/components/styledButton/examples/StyledButton.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/components/styledButton/styles/CdrUnstyledButton.module.scss b/src/components/styledButton/styles/CdrUnstyledButton.module.scss new file mode 100644 index 000000000..a04f398f5 --- /dev/null +++ b/src/components/styledButton/styles/CdrUnstyledButton.module.scss @@ -0,0 +1,6 @@ +@import '../../../styles/settings/index.scss'; +@import './vars/CdrUnstyledButton.vars.scss'; + +.cdr-unstyled-button { + @include cdr-unstyled-button-base-mixin; +} diff --git a/src/components/styledButton/styles/vars/CdrUnstyledButton.vars.scss b/src/components/styledButton/styles/vars/CdrUnstyledButton.vars.scss new file mode 100644 index 000000000..1a7b54b15 --- /dev/null +++ b/src/components/styledButton/styles/vars/CdrUnstyledButton.vars.scss @@ -0,0 +1,17 @@ +@mixin cdr-unstyled-button-base-reset-mixin() { + background-color: transparent; + cursor: pointer; + border: 0; + padding: 0; + appearance: none; + text-align: left; + text-decoration: none; + color: inherit; + touch-action: manipulation; + -webkit-tap-highlight-color: transparent; +} + +@mixin cdr-unstyled-button-base-mixin() { + @include cdr-text-utility-sans-300; + @include cdr-unstyled-button-base-reset-mixin; +} diff --git a/src/components/unstyledButton/CdrUnstyledButton.vue b/src/components/unstyledButton/CdrUnstyledButton.vue new file mode 100644 index 000000000..a2055e5d0 --- /dev/null +++ b/src/components/unstyledButton/CdrUnstyledButton.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/components/unstyledButton/examples/UnstyledButton.vue b/src/components/unstyledButton/examples/UnstyledButton.vue new file mode 100644 index 000000000..3a2c3f4ad --- /dev/null +++ b/src/components/unstyledButton/examples/UnstyledButton.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/components/unstyledButton/styles/CdrStyledButton.module.scss b/src/components/unstyledButton/styles/CdrStyledButton.module.scss new file mode 100644 index 000000000..1448e9943 --- /dev/null +++ b/src/components/unstyledButton/styles/CdrStyledButton.module.scss @@ -0,0 +1,6 @@ +@import '../../../styles/settings/index.scss'; +@import './vars/CdrStyledButton.vars.scss'; + +.cdr-unstyled-button { + @include cdr-styled-button-base-mixin; +} diff --git a/src/components/unstyledButton/styles/vars/CdrStyledButton.vars.scss b/src/components/unstyledButton/styles/vars/CdrStyledButton.vars.scss new file mode 100644 index 000000000..773032638 --- /dev/null +++ b/src/components/unstyledButton/styles/vars/CdrStyledButton.vars.scss @@ -0,0 +1,17 @@ +// @mixin cdr-styled-button-base-mixin() { +// background-color: transparent; +// cursor: pointer; +// border: 0; +// padding: 0; +// appearance: none; +// text-align: left; +// text-decoration: none; +// color: inherit; +// touch-action: manipulation; +// -webkit-tap-highlight-color: transparent; +// } + +@mixin cdr-styled-button-base-mixin() { + // @include cdr-text-utility-sans-300; + // @include cdr-unstyled-button-base-reset-mixin; +} diff --git a/src/dev/DevPage.vue b/src/dev/DevPage.vue index 9aee35b71..8eeebf755 100644 --- a/src/dev/DevPage.vue +++ b/src/dev/DevPage.vue @@ -42,9 +42,6 @@ export default { focusTarget.removeAttribute('tabindex'); }, }, - mounted() { - console.log('BACKSTOP_READY'); // eslint-disable-line - }, }; diff --git a/src/dev/index.js b/src/dev/index.js index bd885ee18..6792f5177 100644 --- a/src/dev/index.js +++ b/src/dev/index.js @@ -1,7 +1,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'; import { createApp } from 'vue'; import routes from './router'; -import DevPage from './DevPage.vue'; //eslint-disable-line +import DevPage from './DevPage.vue'; const router = createRouter({ routes, diff --git a/src/dev/router.js b/src/dev/router.js index 3d28e73aa..6bfead133 100644 --- a/src/dev/router.js +++ b/src/dev/router.js @@ -24,6 +24,7 @@ const routes = [ { path: '/abstract', name: 'Abstract', component: Examples.abstract }, { path: '/accordion', name: 'Accordion', component: Examples.accordion }, { path: '/banner', name: 'Banner', component: Examples.banner }, + { path: '/box', name: 'Box', component: Examples.box }, { path: '/breadcrumbs', name: 'Breadcrumb', component: Examples.breadcrumb }, { path: '/buttons', name: 'Buttons', component: Examples.buttons }, { path: '/captions', name: 'Captions', component: Examples.captions }, @@ -60,6 +61,7 @@ const routes = [ { path: '/toggleButton', name: 'ToggleButton', component: Examples.toggleButton }, { path: '/switch', name: 'Switch', component: Examples.cdrSwitch }, { path: '/tooltip', name: 'Tooltip', component: Examples.tooltip }, + { path: '/unstyledButton', name: 'UnstyledButton', component: Examples.unstyledButton }, // Nightwatch test targets { path: '/e2e-1', component: e2e1 }, diff --git a/src/lib.ts b/src/lib.ts index ec8193a49..73371b038 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -49,5 +49,4 @@ export * from './components/text/presets/textPresets'; /** Type exports */ export * from './types/interfaces'; - - +export * from './types/other'; diff --git a/src/types/other.ts b/src/types/other.ts new file mode 100644 index 000000000..285e4d27e --- /dev/null +++ b/src/types/other.ts @@ -0,0 +1,46 @@ +export type Space = + | 'eighth-x' + | 'quarter-x' + | 'half-x' + | 'three-quarter-x' + | 'one-x' + | 'one-and-a-half-x' + | 'two-x' + | 'three-x' + | 'four-x'; +export type Background = 'primary' | 'secondary' | 'brand-spruce'; +export type Shadow = 'flat' | 'raised' | 'elevated' | 'floating' | 'lifted'; +export type Radius = 'sharp' | 'soft' | 'softer' | 'round'; +export type BorderColor = 'primary' | 'secondary' | 'success' | 'warning' | 'error'; +export type SpacingKey = 'm' | 'mx' | 'my' | 'p' | 'px' | 'py'; +export type OtherKey = 'radius' | 'shadow' | 'background' | 'borderWidth' | 'borderColor'; +export type DirectKey = 'display'; + +/** + * Text component properties + * @type space + */ +// export type Space = (typeof spacing)[number]; + +export interface SpacingProps { + p?: Space; + px?: Space; + py?: Space; + m?: Space; + mx?: Space; + my?: Space; +} + +export interface DirectProps { + display?: string; +} + +export type StylingKey = SpacingKey | DirectKey | OtherKey; + +export interface StylingProps extends SpacingProps, DirectProps { + background?: Background; + radius?: Radius; + shadow?: Shadow; + borderWidth?: Space; + borderColor?: BorderColor; +} diff --git a/src/types/symbols.ts b/src/types/symbols.ts index 965619e71..72b1790d8 100644 --- a/src/types/symbols.ts +++ b/src/types/symbols.ts @@ -13,4 +13,3 @@ export const selectedToggleKey: /** Accordion injection keys */ export const unwrappedKey: InjectionKey> = Symbol(); - \ No newline at end of file From 171ce20bea9395ad022291d877461b9f98433d1c Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Tue, 23 Apr 2024 16:56:18 -0700 Subject: [PATCH 02/70] progress check --- src/components/box/CdrBox.vue | 144 +++++++++++++++--- src/components/box/examples/Box.vue | 24 +-- src/components/box/styles/CdrBox.module.scss | 60 ++++++++ .../box/styles/vars/CdrBox.vars.scss | 0 src/components/box/stylesMap.mts | 50 ------ .../styles/CdrUnstyledButton.module.scss | 4 +- .../styles/CdrStyledButton.module.scss | 6 - .../styles/CdrUnstyledButton.module.scss | 6 + .../styles/vars/CdrStyledButton.vars.scss | 17 --- .../styles/vars/CdrUnstyledButton.vars.scss | 17 +++ src/styles/settings/fluid.vars.scss | 13 ++ 11 files changed, 232 insertions(+), 109 deletions(-) create mode 100644 src/components/box/styles/CdrBox.module.scss create mode 100644 src/components/box/styles/vars/CdrBox.vars.scss delete mode 100644 src/components/box/stylesMap.mts delete mode 100644 src/components/unstyledButton/styles/CdrStyledButton.module.scss create mode 100644 src/components/unstyledButton/styles/CdrUnstyledButton.module.scss delete mode 100644 src/components/unstyledButton/styles/vars/CdrStyledButton.vars.scss create mode 100644 src/components/unstyledButton/styles/vars/CdrUnstyledButton.vars.scss diff --git a/src/components/box/CdrBox.vue b/src/components/box/CdrBox.vue index 313842f93..f6d9cb9be 100644 --- a/src/components/box/CdrBox.vue +++ b/src/components/box/CdrBox.vue @@ -1,8 +1,8 @@ + + diff --git a/src/components/box/examples/Box.vue b/src/components/box/examples/Box.vue index 4921249c4..3ddefa44b 100644 --- a/src/components/box/examples/Box.vue +++ b/src/components/box/examples/Box.vue @@ -1,5 +1,6 @@ diff --git a/src/components/box/examples/Box.vue b/src/components/box/examples/Box.vue index 3ddefa44b..b81709aca 100644 --- a/src/components/box/examples/Box.vue +++ b/src/components/box/examples/Box.vue @@ -11,12 +11,12 @@ export interface Example { const boxes: Example[] = [ { - description: 'This is a box without any props', - props: {}, + description: 'This is a box without any specific props', + props: { 'data-id': 'test' }, }, { description: - 'This is a box with radius, shadow, borderColor, surface, elevation and position props applied.', + 'This is a box with radius, shadow, borderColor, surface, elevation, position, margin, and padding props applied.', props: { radius: 'round', shadow: 'elevated', @@ -24,6 +24,8 @@ const boxes: Example[] = [ surface: 'secondary', elevation: 'modal', position: 'relative', + m: 'one-x', + p: 'one-x', }, }, { diff --git a/src/components/box/styles/CdrBox.module.scss b/src/components/box/styles/CdrBox.module.scss index 980cd5565..dd7ad9844 100644 --- a/src/components/box/styles/CdrBox.module.scss +++ b/src/components/box/styles/CdrBox.module.scss @@ -3,28 +3,34 @@ .cdr-box { @include cdr-box-base-mixin; + // @include cdr-box-border-mixin; + // @include cdr-box-radius-mixin; + // @include cdr-box-shadow-mixin; + // @include cdr-box-surface-mixin; + // @include cdr-box-elevation-mixin; + // @include cdr-box-palette-mixin; } -.cdr-box__border { +.cdr-box--border { @include cdr-box-border-mixin; } -.cdr-box__radius { +.cdr-box--radius { @include cdr-box-radius-mixin; } -.cdr-box__shadow { +.cdr-box--shadow { @include cdr-box-shadow-mixin; } -.cdr-box__surface { +.cdr-box--surface { @include cdr-box-surface-mixin; } -.cdr-box__elevation { +.cdr-box--elevation { @include cdr-box-elevation-mixin; } -.cdr-box__palette { +.cdr-box--palette { @include cdr-box-palette-mixin; } \ No newline at end of file diff --git a/src/components/box/styles/vars/CdrBox.vars.scss b/src/components/box/styles/vars/CdrBox.vars.scss index 32dc82e67..363d44c43 100644 --- a/src/components/box/styles/vars/CdrBox.vars.scss +++ b/src/components/box/styles/vars/CdrBox.vars.scss @@ -1,5 +1,6 @@ @mixin cdr-box-base-mixin() { - --cdr-box-border-width-default: var(--cdr-space-inset-eighth-x); + --cdr-color-background-transparent: transparent; + --cdr-box-border-width-default: 0; --cdr-box-border-style-default: solid; --cdr-box-border-color-default: var(--cdr-color-border-primary); --cdr-box-radius-default: var(--cdr-radius-sharp); diff --git a/src/components/examples.js b/src/components/examples.js index f1a2fa3e4..e76a9b242 100644 --- a/src/components/examples.js +++ b/src/components/examples.js @@ -8,7 +8,7 @@ import captions from 'componentsdir/caption/examples/Caption.vue'; import card from 'componentsdir/card/examples/Cards.vue'; import checkbox from 'componentsdir/checkbox/examples/checkboxes.vue'; import chip from 'componentsdir/chip/examples/Chip.vue'; -import choreographer from 'componentsdir/choreographer/examples/Choreographer.vue' +import choreographer from 'componentsdir/choreographer/examples/Choreographer.vue'; import container from 'componentsdir/container/examples/Container.vue'; import formGroup from 'componentsdir/formGroup/examples/FormGroup.vue'; import grid from 'componentsdir/grid/examples/Grid.vue'; @@ -30,6 +30,7 @@ import rating from 'componentsdir/rating/examples/Ratings.vue'; import selects from 'componentsdir/select/examples/Selects.vue'; import skeleton from 'componentsdir/skeleton/examples/Skeleton.vue'; import splitSurface from 'componentsdir/splitSurface/examples/SplitSurface.vue'; +import styledButton from 'componentsdir/styledButton/examples/StyledButton.vue'; import tables from 'componentsdir/table/examples/Table.vue'; import tabs from 'componentsdir/tabs/examples/Tabs.vue'; import texts from 'componentsdir/text/examples/Text.vue'; @@ -73,6 +74,7 @@ export default { selects, skeleton, splitSurface, + styledButton, tables, tabs, texts, diff --git a/src/components/styledButton/CdrStyledButton.vue b/src/components/styledButton/CdrStyledButton.vue index 449f98871..f71262c26 100644 --- a/src/components/styledButton/CdrStyledButton.vue +++ b/src/components/styledButton/CdrStyledButton.vue @@ -1,5 +1,6 @@