Skip to content

Commit

Permalink
feat(components): upgrading storybook to v7 (#2064)
Browse files Browse the repository at this point in the history
  • Loading branch information
owilliams320 authored Nov 1, 2023
1 parent 053e699 commit efd2598
Show file tree
Hide file tree
Showing 53 changed files with 32,458 additions and 50,619 deletions.
3 changes: 3 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ module.exports = {
'@storybook/addon-interactions',
'storybook-dark-mode',
],
features: {
legacyMdx1: true, // 👈 Enables MDX v1 support
},
staticDirs: [join(__dirname, './public')],
};
4 changes: 1 addition & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export const parameters = {
},
darkMode: {
// Override the default dark theme
dark: {
...darkTheme,
},
dark: darkTheme,
// Override the default light theme
light: lightTheme,

Expand Down
104 changes: 51 additions & 53 deletions .storybook/theme/markdown-elements.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.sb-show-main {
background-color: var(--mdc-theme-background);
}
.sb-show-main .sbdocs-wrapper {
background-color: var(--mdc-theme-background);
background-image: url(./globe.svg);
Expand All @@ -20,35 +23,35 @@
margin-top: 2rem;
}

table.docblock-argstable {
border-collapse: unset;
table {
border-collapse: collapse;
border-radius: 0;

tbody {
box-shadow: none;
}

tr {
height: 3rem;
}
tr {
height: 3rem;
}

td {
background: transparent;
border-bottom: 1px solid var(--mdc-theme-border);
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-font-family);
font-size: var(--mdc-typography-body1-font-size);
font-weight: var(--mdc-typography-body1-font-weight);
line-height: var(--mdc-typography-body1-line-height);
min-height: 3rem;
padding: 0 1rem;
vertical-align: middle;
td {
background: transparent;
border-bottom: 1px solid var(--mdc-theme-border);
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-font-family);
font-size: var(--mdc-typography-body1-font-size);
font-weight: var(--mdc-typography-body1-font-weight);
line-height: var(--mdc-typography-body1-line-height);
min-height: 3rem;
padding: 0 1rem;
vertical-align: middle;

&:first-of-type {
padding-left: 1rem !important;
}
&:last-of-type {
padding-right: 1rem !important;
}
&:first-of-type {
padding-left: 1rem !important;
}
&:last-of-type {
padding-right: 1rem !important;
}
}

Expand Down Expand Up @@ -100,7 +103,7 @@
}
}

a.link-item {
a.link-item[href] {
display: block;
padding: 16px;
border: 1px solid var(--mdc-theme-border);
Expand Down Expand Up @@ -173,20 +176,20 @@
border-color: var(--mdc-theme-surface-canvas);
}
}
.sbdocs {
&-h1,
&-h2,
&-h3,
&-h4,
&-h5,
&-h6 {
&:first-of-type {
margin-top: 0;
padding-top: 4rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
&:first-of-type {
margin-top: 0;
padding-top: 4rem;
}
}
.sbdocs-h1,

h1,
.sbdocs-title {
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline1-font-family);
Expand All @@ -196,14 +199,9 @@
margin: 0;
padding-bottom: 4rem;
padding-top: 2rem;

&#covalent-design-system {
padding-top: 0;
max-width: 40rem;
}
}
.sbdocs-h2,
.sbdocs-h2:first-of-type {
h2,
h2:first-of-type {
border: none;
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline2-font-family);
Expand All @@ -214,7 +212,7 @@
padding-bottom: 1.5rem;
padding-top: 2rem;
}
.sbdocs-h3 {
h3 {
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline3-font-family);
font-size: var(--mdc-typography-headline3-font-size);
Expand All @@ -224,7 +222,7 @@
padding-bottom: 1.5rem;
padding-top: 2rem;
}
.sbdocs-h4 {
h4 {
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline4-font-family);
font-size: var(--mdc-typography-headline4-font-size);
Expand All @@ -234,7 +232,7 @@
padding-bottom: 1.5rem;
padding-top: 2rem;
}
.sbdocs-h5 {
h5 {
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline5-font-family);
font-size: var(--mdc-typography-headline5-font-size);
Expand All @@ -244,7 +242,7 @@
padding-bottom: 1.5rem;
padding-top: 2rem;
}
.sbdocs-h6 {
h6 {
color: var(--mdc-theme-text-primary-on-background);
font-family: var(--mdc-typography-headline6-font-family);
font-size: var(--mdc-typography-headline6-font-size);
Expand All @@ -254,17 +252,17 @@
padding-bottom: 1.5rem;
padding-top: 2rem;
}
.sbdocs-hr {
hr {
border-color: var(--mdc-theme-border);
height: 1px;
margin: 5rem 0 0;
padding: 0 0 3rem;
}
.sbdocs-ul {
ul {
margin: 0;
padding-top: 0.5rem;
}
.sbdocs-li {
li {
color: var(--mdc-theme-text-secondary-on-background);
font-family: var(--mdc-typography-font-family);
font-size: var(--mdc-typography-body1-font-size);
Expand All @@ -276,11 +274,11 @@
&:first-of-type {
padding-top: 0;
}
.sbdocs-ul {
ul {
padding-top: 0.75rem;
}
}
.sbdocs-p {
p {
color: var(--mdc-theme-text-secondary-on-background);
font-family: var(--mdc-typography-font-family);
font-size: var(--mdc-typography-body1-font-size);
Expand All @@ -291,13 +289,13 @@
padding-bottom: 0.75rem;
padding-top: 0;
}
.sbdocs-table {
table {
font-family: var(--mdc-typography-subtitle2-font-family);

thead th {
height: 3.5rem;
}
tbody td {
td {
height: 3rem;
}
tr {
Expand Down
1 change: 1 addition & 0 deletions libs/components/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ module.exports = {
assetsInclude: ['**/*.html'],
});
},
framework: '@storybook/html-vite'
};
20 changes: 8 additions & 12 deletions libs/components/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import anysort from 'anysort';

import { parameters as mainParameters } from '../../../.storybook/preview';

import '../theme/theme.scss';
import '../../../.storybook/theme/markdown-elements.scss';

export const parameters = {
options: {
storySort: (previous, next) => {
const [previousStory, previousMeta] = previous;
const [nextStory, nextMeta] = next;

return anysort(previousMeta.kind, nextMeta.kind, [
storySort: {
order: [
'Overview',
'Introduction',
'Guides/**',
'Patterns/**',
'Basics/**',
'Components/**/Overview',
]);
'Guides',
'Patterns',
'Basics',
'Components',
],
},
},
...mainParameters,
Expand Down
31 changes: 8 additions & 23 deletions libs/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,19 @@ All components are published in npm and available on any CDN that host npm modul

```html
<!-- using a specific version -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@covalent/components@4.10.0/theme.css"
/>
<script
type="module"
src="https://cdn.jsdelivr.net/npm/@covalent/components@4.10.0/index.js"
></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@covalent/components@x.x.x/index.mjs"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@covalent/components@x.x.x/style.css" />

<!-- using the latest version -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@covalent/components@latest/theme.css"
/>
<script
type="module"
src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/index.js"
></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/index.mjs"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@covalent/components@latest/style.css" />
```

the component bundles are also available individually

```html
<!-- just include the button component -->
<script
type="module"
src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/button.js"
></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/button.mjs"></script>
```

### Basic usage
Expand All @@ -48,8 +33,8 @@ once the script is loaded, its now possible to start using our custom HTML eleme
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@covalent/components@latest/theme.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/index.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@covalent/components@latest/index.mjs"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@covalent/components@latest/style.css" />
</head>
<body>
<cv-button raised>Hello world<cv-button>
Expand Down Expand Up @@ -79,7 +64,7 @@ Applications using angular can use covalent components in the same way they use
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './app.component';

import '@covalent/components/button.js';
import '@covalent/components/button';

@component({
standalone: true,
Expand Down
19 changes: 14 additions & 5 deletions libs/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"import": "./index.mjs",
"require": "./index.js"
},
"./style.css": {
"import": "./style.css",
"require": "./style.css"
},
"./action-ribbon": {
"types": "./action-ribbon/action-ribbon.d.ts",
"import": "./action-ribbon.mjs",
Expand Down Expand Up @@ -40,6 +44,16 @@
"import": "./card.mjs",
"require": "./card.js"
},
"./chip": {
"types": "./chips/chip.d.ts",
"import": "./chip.mjs",
"require": "./chip.js"
},
"./chip-set": {
"types": "./chip/chip-set.d.ts",
"import": "./chip-set.mjs",
"require": "./chip-set.js"
},
"./circular-progress": {
"types": "./circular-progress/circular-progress.d.ts",
"import": "./circular-progress.mjs",
Expand Down Expand Up @@ -100,11 +114,6 @@
"import": "./list.mjs",
"require": "./list.js"
},
"./list/list-expansion": {
"types": "./list/list-expansion.d.ts",
"import": "./list-expansion.mjs",
"require": "./list-expansion.js"
},
"./list/list-item": {
"types": "./list/list-item.d.ts",
"import": "./list-item.mjs",
Expand Down
8 changes: 3 additions & 5 deletions libs/components/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"serve": {
"executor": "nx:run-commands",
"options": {
"commands": [
"cd libs/components/ && vite"
],
"commands": ["cd libs/components/ && vite"],
"parallel": false
}
},
Expand Down Expand Up @@ -57,7 +55,7 @@
"options": {
"commands": [
{
"command": "npx start-storybook -c libs/components/.storybook"
"command": "storybook dev -c libs/components/.storybook"
}
]
}
Expand All @@ -67,7 +65,7 @@
"options": {
"commands": [
{
"command": "npx build-storybook -c libs/components/.storybook -o dist/storybook/components"
"command": "storybook build -c libs/components/.storybook -o dist/storybook/components"
}
]
}
Expand Down
Loading

0 comments on commit efd2598

Please sign in to comment.