Skip to content

Commit 3922041

Browse files
authored
Merge pull request #261 from qwikifiers/pr-storybook
2 parents cab9ef1 + 3898db8 commit 3922041

File tree

18 files changed

+3302
-4761
lines changed

18 files changed

+3302
-4761
lines changed

cla-signs/v1/cla.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@
217217
"pullRequestNo": 262
218218
}
219219
]
220-
}
220+
}

package.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131
"@nrwl/storybook": "15.8.7",
3232
"@nrwl/vite": "15.8.7",
3333
"@nrwl/workspace": "15.8.7",
34-
"@storybook/addon-essentials": "7.0.0-beta.30",
35-
"@storybook/addon-interactions": "7.0.0-beta.30",
36-
"@storybook/addon-links": "7.0.0-beta.30",
37-
"@storybook/blocks": "7.0.0-beta.30",
38-
"@storybook/builder-vite": "0.4.2",
39-
"@storybook/html": "7.0.0-beta.30",
40-
"@storybook/html-vite": "7.0.0-beta.30",
34+
"@storybook/addon-a11y": "7.0.0-rc.10",
35+
"@storybook/addon-essentials": "7.0.0-rc.7",
36+
"@storybook/addon-interactions": "7.0.0-rc.7",
37+
"@storybook/addon-links": "7.0.0-rc.7",
38+
"@storybook/blocks": "7.0.0-rc.7",
39+
"@storybook/builder-vite": "7.0.0-rc.7",
40+
"@storybook/html": "7.0.0-rc.7",
41+
"@storybook/html-vite": "7.0.0-rc.7",
42+
"@storybook/jest": "0.0.10",
43+
"@storybook/test-runner": "0.10.0-next.12",
4144
"@storybook/testing-library": "0.0.13",
4245
"@types/eslint": "8.21.3",
4346
"@types/node": "18.15.3",
@@ -47,18 +50,21 @@
4750
"@vitest/ui": "^0.28.5",
4851
"all-contributors-cli": "^6.24.0",
4952
"autoprefixer": "^10.4.13",
53+
"axe-core": "4.6.3",
5054
"commitizen": "^4.3.0",
5155
"commitlint": "^17.4.3",
5256
"country-list-json": "1.1.0",
53-
"cypress": "^12.6.0",
54-
"cypress-ct-qwik": "0.0.5",
57+
"cypress": "^12.9.0",
58+
"cypress-axe": "1.4.0",
59+
"cypress-ct-qwik": "0.3.0",
5560
"cz-conventional-changelog": "^3.3.0",
5661
"daisyui": "^2.50.1",
5762
"danger": "11.2.4",
5863
"eslint": "8.36.0",
5964
"eslint-config-prettier": "8.6.0",
6065
"eslint-plugin-cypress": "^2.12.1",
6166
"eslint-plugin-qwik": "0.23.0",
67+
"eslint-plugin-storybook": "^0.6.11",
6268
"html-webpack-plugin": "^5.5.0",
6369
"husky": "^8.0.3",
6470
"jsdom": "~20.0.3",
@@ -72,14 +78,16 @@
7278
"prettier": "2.8.6",
7379
"pretty-quick": "^3.1.3",
7480
"qwik-nx": "0.14.0",
81+
"react": "18.2.0",
82+
"react-dom": "18.2.0",
7583
"sass": "1.58.1",
76-
"storybook": "7.0.0-beta.30",
84+
"storybook": "7.0.0-rc.7",
7785
"storybook-framework-qwik": "0.0.8",
7886
"tailwindcss": "^3.2.6",
7987
"ts-node": "10.9.1",
8088
"typescript": "5.0.2",
8189
"undici": "5.21.0",
82-
"vite": "4.1.2",
90+
"vite": "4.2.1",
8391
"vite-plugin-dts": "~1.7.3",
8492
"vite-plugin-eslint": "^1.8.1",
8593
"vite-tsconfig-paths": "4.0.7",

packages/headless/.storybook/main.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
import { qwikVite } from '@builder.io/qwik/optimizer';
2-
import { rootMain } from '../../../.storybook/main';
3-
4-
import type { StorybookViteConfig } from '@storybook/builder-vite';
2+
import { resolve } from 'path';
3+
import { StorybookConfig } from 'storybook-framework-qwik';
4+
// import { rootMain } from '../../../.storybook/main';
55

66
import { mergeConfig } from 'vite';
77
import viteTsConfigPaths from 'vite-tsconfig-paths';
88

9-
const config: StorybookViteConfig = {
10-
...rootMain,
11-
core: {
12-
...rootMain.core,
13-
builder: '@storybook/builder-vite',
14-
},
15-
stories: [
16-
...rootMain.stories,
17-
'../src/lib/**/*.stories.mdx',
18-
'../src/lib/**/*.stories.@(js|jsx|ts|tsx)',
9+
const config: StorybookConfig = {
10+
// ...rootMain,
11+
12+
addons: [
13+
'@storybook/addon-links',
14+
'@storybook/addon-essentials',
15+
'@storybook/addon-interactions',
16+
'@storybook/addon-a11y',
17+
'@storybook/addon-coverage',
1918
],
20-
addons: ['@storybook/addon-essentials', ...(rootMain.addons || [])],
19+
// addons: ['@storybook/addon-essentials', ...(rootMain.addons || [])],
20+
2121
framework: {
2222
name: 'storybook-framework-qwik',
2323
},
24+
core: {
25+
// ...rootMain.core,
26+
renderer: 'storybook-framework-qwik',
27+
},
28+
stories: [
29+
// ...rootMain.stories,
30+
'../src/components/**/*.stories.mdx',
31+
'../src/components/**/*.stories.@(js|jsx|ts|tsx)',
32+
],
33+
2434
viteFinal: async (config: any) => {
2535
return mergeConfig(config, {
2636
plugins: [
27-
viteTsConfigPaths({
28-
root: '../../../',
37+
qwikVite({
38+
vendorRoots: [__dirname],
39+
srcDir: resolve(__dirname, '../src'),
2940
}),
30-
qwikVite(),
41+
viteTsConfigPaths(),
3142
],
3243
});
3344
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
window.global = window;
3+
</script>

packages/headless/.storybook/preview.ts

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// import { qwikCityDecorator } from 'storybook-framework-qwik/qwik-city-decorator';
2+
import { Parameters } from 'storybook-framework-qwik';
3+
import type { Preview } from '@storybook/types';
4+
// export const decorators: Decorator[] = [qwikCityDecorator];
5+
6+
// const preview: Preview = {
7+
// parameters: {
8+
// backgrounds: {
9+
// default: 'light'
10+
// },
11+
// actions: { argTypesRegex: '^on[A-Z].*' },
12+
// controls: {
13+
// matchers: {
14+
// color: /(background|color)$/i,
15+
// date: /Date$/
16+
// }
17+
// }
18+
// }
19+
// }
20+
21+
// export default preview
22+
23+
export const parameters: Parameters = {
24+
a11y: {
25+
config: {},
26+
options: {
27+
checks: { 'color-contrast': { options: { noScroll: true } } },
28+
restoreScroll: true,
29+
},
30+
},
31+
options: {
32+
showRoots: true,
33+
},
34+
docs: {
35+
iframeHeight: '200px',
36+
},
37+
};

packages/headless/.storybook/tsconfig.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
"emitDecoratorMetadata": true
55
},
66

7-
"exclude": ["../**/*.spec.ts"],
7+
"exclude": [
8+
"../**/*.spec.ts",
9+
"../**/*.test.ts",
10+
"../**/*.spec.tsx",
11+
"../**/*.test.tsx"
12+
],
813
"include": [
914
"../src/**/*.stories.ts",
1015
"../src/**/*.stories.js",
1116
"../src/**/*.stories.jsx",
1217
"../src/**/*.stories.tsx",
1318
"../src/**/*.stories.mdx",
1419
"*.ts",
15-
"*.js"
20+
"*.js",
21+
"preview.tsx"
1622
]
1723
}

packages/headless/cypress.config.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import { defineConfig } from 'cypress';
2-
import { mergeConfig } from 'vite';
3-
import viteConfig from './vite.config';
42

5-
const cypressConfig = {
3+
export default defineConfig({
64
component: {
75
specPattern: '**/*.spec.{js,jsx,ts,tsx}',
86
devServer: {
7+
framework: 'cypress-ct-qwik',
98
bundler: 'vite',
10-
viteConfig,
119
},
1210
},
13-
};
14-
15-
export default defineConfig(
16-
cypressConfig as Cypress.ConfigOptions<typeof cypressConfig>
17-
);
11+
});

packages/headless/cypress/support/component-index.html

Lines changed: 1 addition & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -4,124 +4,9 @@
44
<meta charset="utf-8" />
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7-
<title>headless Components App</title>
7+
<title>Headless Components App</title>
88
</head>
99
<body>
1010
<div data-cy-root></div>
11-
<script type="text/javascript">
12-
((e, t) => {
13-
const n = '__q_context__',
14-
o = window,
15-
i = new Set(),
16-
s = (t) => e.querySelectorAll(t),
17-
r = (e, t, n = t.type) => {
18-
s('[on' + e + '\\:' + n + ']').forEach((o) => f(o, e, t, n));
19-
},
20-
a = (e, t) => e.getAttribute(t),
21-
l = (t) => {
22-
if (void 0 === t._qwikjson_) {
23-
let n = (t === e.documentElement ? e.body : t).lastElementChild;
24-
for (; n; ) {
25-
if ('SCRIPT' === n.tagName && 'qwik/json' === a(n, 'type')) {
26-
t._qwikjson_ = JSON.parse(
27-
n.textContent.replace(/\\x3C(\/?script)/g, '<$1')
28-
);
29-
break;
30-
}
31-
n = n.previousElementSibling;
32-
}
33-
}
34-
},
35-
c = (e, t) => new CustomEvent(e, { detail: t }),
36-
f = async (t, o, i, s = i.type) => {
37-
const r = 'on' + o + ':' + s;
38-
t.hasAttribute('preventdefault:' + s) && i.preventDefault();
39-
const c = t._qc_,
40-
f = null == c ? void 0 : c.li.filter((e) => e[0] === r);
41-
if (f && f.length > 0) {
42-
for (const e of f)
43-
await e[1].getFn([t, i], () => t.isConnected)(i, t);
44-
return;
45-
}
46-
const d = a(t, r);
47-
if (d) {
48-
const o = t.closest('[q\\:container]'),
49-
s = new URL(a(o, 'q:base'), e.baseURI);
50-
for (const r of d.split('\n')) {
51-
const a = new URL(r, s),
52-
c = a.hash.replace(/^#?([^?[|]*).*$/, '$1') || 'default',
53-
f = performance.now(),
54-
d = import(a.href.split('#')[0]);
55-
l(o);
56-
const p = b(await d, c),
57-
w = e[n];
58-
if (t.isConnected)
59-
try {
60-
(e[n] = [t, i, a]),
61-
u('qsymbol', { symbol: c, element: t, reqTime: f }),
62-
await p(i, t);
63-
} finally {
64-
e[n] = w;
65-
}
66-
}
67-
}
68-
},
69-
u = (t, n) => {
70-
e.dispatchEvent(c(t, n));
71-
},
72-
b = (e, t) => {
73-
if (t in e) return e[t];
74-
for (const n of Object.values(e))
75-
if ('object' == typeof n && n && t in n) return n[t];
76-
},
77-
d = (e) => e.replace(/([A-Z])/g, (e) => '-' + e.toLowerCase()),
78-
p = async (e) => {
79-
let t = d(e.type),
80-
n = e.target;
81-
for (r('-document', e, t); n && n.getAttribute; )
82-
await f(n, '', e, t),
83-
(n =
84-
e.bubbles && !0 !== e.cancelBubble ? n.parentElement : null);
85-
},
86-
w = (e) => {
87-
r('-window', e, d(e.type));
88-
},
89-
q = () => {
90-
var n;
91-
const r = e.readyState;
92-
if (
93-
!t &&
94-
('interactive' == r || 'complete' == r) &&
95-
((t = 1),
96-
u('qinit'),
97-
(null != (n = o.requestIdleCallback) ? n : o.setTimeout).bind(o)(
98-
() => u('qidle')
99-
),
100-
i.has('qvisible'))
101-
) {
102-
const e = s('[on\\:qvisible]'),
103-
t = new IntersectionObserver((e) => {
104-
for (const n of e)
105-
n.isIntersecting &&
106-
(t.unobserve(n.target),
107-
f(n.target, '', c('qvisible', n)));
108-
});
109-
e.forEach((e) => t.observe(e));
110-
}
111-
},
112-
v = (e, t, n, o = !1) => e.addEventListener(t, n, { capture: o }),
113-
y = (t) => {
114-
for (const n of t)
115-
i.has(n) || (v(e, n, p, !0), v(o, n, w), i.add(n));
116-
};
117-
if (!e.qR) {
118-
const t = o.qwikevents;
119-
Array.isArray(t) && y(t),
120-
(o.qwikevents = { push: (...e) => y(e) }),
121-
v(e, 'readystatechange', q),
122-
q();
123-
}
124-
})(document);
125-
</script>
12611
</body>
12712
</html>

packages/headless/cypress/support/component.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,28 @@
1313
// https://on.cypress.io/configuration
1414
// ***********************************************************
1515

16+
import { addQwikLoader, mount } from 'cypress-ct-qwik';
17+
18+
addQwikLoader();
19+
1620
// Import commands.ts using ES2015 syntax:
1721
import './commands';
22+
import 'cypress-axe';
23+
24+
// Augment the Cypress namespace to include type definitions for
25+
// your custom command.
26+
// Alternatively, can be defined in cypress/support/component.d.ts
27+
// with a <reference path="./component" /> at the top of your spec.
28+
declare global {
29+
// eslint-disable-next-line @typescript-eslint/no-namespace
30+
namespace Cypress {
31+
interface Chainable {
32+
mount: typeof mount;
33+
}
34+
}
35+
}
36+
37+
Cypress.Commands.add('mount', mount);
38+
39+
// Example use:
40+
// cy.mount(MyComponent)

0 commit comments

Comments
 (0)