@guardian/stand 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,3 +13,7 @@ Stand is component library for Guardian editorial tools. It is co-located within
13
13
  - Run `pnpm install` to install dependencies.
14
14
  - Run `pnpm build` to build, this makes any changes available to flexible-frontend
15
15
  - Run `pnpm storybook` to run Storybook
16
+
17
+ ## Contributing
18
+
19
+ See the [Contributing to Stand](./CONTRIBUTING.md) documentation
@@ -0,0 +1,3 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { Byline } from '../src';
3
+ export declare const BylineWithMockSearchContributors: (props: Omit<ComponentProps<typeof Byline>, 'searchContributors' | 'handleSave'>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * See https://playwright.dev/docs/test-configuration.
3
+ */
4
+ declare const _default: import("@playwright/experimental-ct-react17").PlaywrightTestConfig<{}, {}>;
5
+ export default _default;
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "types": "./dist/types/src/index.d.ts",
7
7
  "import": "./dist/index.js",
8
8
  "require": "./dist/index.cjs"
9
9
  },
10
+ "files": [
11
+ "dist"
12
+ ],
10
13
  "main": "./dist/index.cjs",
11
14
  "types": "./dist/types/src/index.d.ts",
12
15
  "dependencies": {
@@ -26,16 +29,15 @@
26
29
  "@guardian/eslint-config": "12.0.0",
27
30
  "@guardian/prettier": "8.0.1",
28
31
  "@guardian/tsconfig": "1.0.0",
32
+ "@playwright/experimental-ct-react17": "^1.55.1",
29
33
  "@rollup/plugin-commonjs": "28.0.6",
30
34
  "@rollup/plugin-node-resolve": "16.0.1",
31
35
  "@rollup/plugin-typescript": "12.1.4",
32
36
  "@storybook/addon-docs": "^9.1.7",
33
37
  "@storybook/addon-themes": "^9.1.7",
34
38
  "@storybook/react-vite": "^9.1.7",
35
- "@testing-library/jest-dom": "6.8.0",
36
- "@testing-library/react": "12.1.5",
37
- "@testing-library/user-event": "14.6.1",
38
39
  "@types/jest": "30.0.0",
40
+ "@types/node": "^24.5.2",
39
41
  "@types/react": "17.0.76",
40
42
  "@types/react-dom": "17.0.25",
41
43
  "eslint": "9.36.0",
@@ -69,6 +71,7 @@
69
71
  "build": "rimraf dist && rollup -c",
70
72
  "storybook": "storybook dev -p 6007",
71
73
  "build-storybook": "storybook build",
72
- "test": "jest"
74
+ "test": "jest",
75
+ "test-e2e": "playwright test -c playwright-ct.config.ts"
73
76
  }
74
77
  }
@@ -1,8 +0,0 @@
1
- # Changesets
2
-
3
- Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
- with multi-package repos, or single-package repos to help you version and publish your code. You can
5
- find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
-
7
- We have a quick list of common questions to get you started engaging with this project in
8
- [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
package/.prettierrc DELETED
@@ -1 +0,0 @@
1
- "@guardian/prettier"
@@ -1,12 +0,0 @@
1
- import type { StorybookConfig } from '@storybook/react-vite';
2
-
3
- const config: StorybookConfig = {
4
- stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5
- addons: ['@storybook/addon-docs'],
6
- framework: {
7
- name: '@storybook/react-vite',
8
- options: {},
9
- },
10
- };
11
-
12
- export default config;
@@ -1,83 +0,0 @@
1
- import { Global } from '@emotion/react';
2
- import { css } from '@emotion/react';
3
- import { withThemeFromJSXProvider } from '@storybook/addon-themes';
4
- import type { Preview } from '@storybook/react-vite';
5
-
6
- const ASSETS_URL = 'https://interactive.guim.co.uk/fonts/guss-webfonts/';
7
-
8
- const Fonts = css`
9
- @font-face {
10
- font-family: 'Guardian Agate Sans';
11
- src: url('${ASSETS_URL}GuardianAgateSans1Web/GuardianAgateSans1Web-Regular.woff2')
12
- format('woff2');
13
- font-weight: 400;
14
- font-style: 'normal';
15
- font-display: 'fallback';
16
- }
17
- @font-face {
18
- font-family: 'Guardian Agate Sans';
19
- src: url('${ASSETS_URL}GuardianAgateSans1Web/GuardianAgateSans1Web-Bold.woff2')
20
- format('woff2');
21
- font-weight: 700;
22
- font-style: normal;
23
- font-display: swap;
24
- }
25
- @font-face {
26
- font-family: 'Guardian Agate Sans';
27
- src: url('${ASSETS_URL}GuardianAgateSans1Web/GuardianAgateSans1Web-RegularItalic.woff2')
28
- format('woff2');
29
- font-weight: 400;
30
- font-style: italic;
31
- font-display: swap;
32
- }
33
- @font-face {
34
- font-family: 'Guardian Agate Sans';
35
- src: url('${ASSETS_URL}GuardianAgateSans1Web/GuardianAgateSans1Web-BoldItalic.woff2')
36
- format('woff2');
37
- font-weight: 700;
38
- font-style: italic;
39
- font-display: swap;
40
- }
41
- `;
42
-
43
- const globalFont = {
44
- fontFamily: '"Guardian Agate Sans", "Arial", sans-serif',
45
- fontSize: '13px',
46
- lineHeight: '1.2',
47
- color: '#292929',
48
- };
49
-
50
- const globalStyles = css({
51
- html: {
52
- height: '100vh',
53
- width: '100vw',
54
- },
55
- body: {
56
- ...globalFont,
57
- minHeight: '100vh',
58
- width: '100vw',
59
- margin: '0 auto',
60
- },
61
- });
62
-
63
- const GlobalStyles = () => <Global styles={[Fonts, globalStyles]} />;
64
-
65
- const preview: Preview = {
66
- parameters: {
67
- controls: {
68
- matchers: {
69
- color: /(background|color)$/i,
70
- date: /Date$/i,
71
- },
72
- },
73
- },
74
- decorators: [
75
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call -- withThemeFromJSXProvider is a valid function
76
- withThemeFromJSXProvider({
77
- GlobalStyles, // Adds GlobalStyles to all stories
78
- }),
79
- ],
80
- };
81
-
82
- // eslint-disable-next-line import/no-default-export -- storybook expects default
83
- export default preview;
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # @guardian/stand
2
-
3
- ## 0.0.2
4
-
5
- ### Patch Changes
6
-
7
- - cf56688: Add changesets
@@ -1,10 +0,0 @@
1
- declare const mockEditorViewMethods: {
2
- posAtCoords: () => null;
3
- coordsAtPos: () => {
4
- left: number;
5
- right: number;
6
- top: number;
7
- bottom: number;
8
- };
9
- };
10
- export { mockEditorViewMethods };
package/eslint.config.js DELETED
@@ -1,14 +0,0 @@
1
- // For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
2
- import storybook from 'eslint-plugin-storybook';
3
-
4
- import guardian from '@guardian/eslint-config';
5
-
6
- export default [
7
- {
8
- ignores: ['dist'],
9
- },
10
- ...guardian.configs.recommended,
11
- ...guardian.configs.jest,
12
- ...guardian.configs.react,
13
- ...storybook.configs['flat/recommended'],
14
- ];
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
package/jest.config.js DELETED
@@ -1,12 +0,0 @@
1
- import { createDefaultPreset } from 'ts-jest';
2
-
3
- const tsJestTransformCfg = createDefaultPreset().transform;
4
-
5
- /** @type {import("jest").Config} **/
6
- export default {
7
- testEnvironment: 'jsdom',
8
- setupFilesAfterEnv: ['<rootDir>/jest-setup-after-env.ts'],
9
- transform: {
10
- ...tsJestTransformCfg,
11
- },
12
- };
package/rollup.config.js DELETED
@@ -1,49 +0,0 @@
1
- import commonjs from '@rollup/plugin-commonjs';
2
- import resolve from '@rollup/plugin-node-resolve';
3
- import typescript from '@rollup/plugin-typescript';
4
- import esbuild from 'rollup-plugin-esbuild';
5
- import { nodeExternals } from 'rollup-plugin-node-externals';
6
-
7
- /**
8
- * @returns {import("rollup").RollupOptions[]}
9
- */
10
- export default [
11
- {
12
- input: 'src/index.ts',
13
- output: {
14
- dir: 'dist',
15
- format: 'esm',
16
- preserveModules: true,
17
- preserveModulesRoot: 'src',
18
- },
19
- plugins: [
20
- resolve(),
21
- nodeExternals(),
22
- esbuild({
23
- jsx: 'automatic',
24
- }),
25
- typescript({
26
- tsconfig: './tsconfig.json',
27
- outDir: 'dist/types',
28
- }),
29
- ],
30
- },
31
- {
32
- input: 'src/index.ts',
33
- output: {
34
- dir: 'dist',
35
- format: 'cjs',
36
- preserveModules: true,
37
- preserveModulesRoot: 'src',
38
- entryFileNames: '[name].cjs',
39
- },
40
- plugins: [
41
- resolve(),
42
- nodeExternals(),
43
- commonjs(),
44
- esbuild({
45
- jsx: 'automatic',
46
- }),
47
- ],
48
- },
49
- ];
@@ -1,186 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Byline } from './Byline';
3
- import { contributors } from './contributors-fixture';
4
- import type { TaggedContributor } from './lib';
5
-
6
- const searchContributors = (
7
- selectedText: string,
8
- ): Promise<TaggedContributor[]> => {
9
- return new Promise<TaggedContributor[]>((resolve) => {
10
- const results = contributors
11
- .filter((name) =>
12
- name.toLowerCase().includes(selectedText.toLowerCase()),
13
- )
14
- .map((name, index) => ({
15
- path: `profile/${name.toLowerCase().replace(/\s/g, '-')}`,
16
- label: name,
17
- type: 'Contributor',
18
- tagId: `${index + 1}`,
19
- // show internal label for every 5th contributor for testing internalLabel
20
- internalLabel:
21
- index % 5 === 0 ? `${name} (internal)` : undefined,
22
- }))
23
- .slice(0, 20);
24
-
25
- return resolve(results);
26
- });
27
- };
28
-
29
- const disableSnapshot = {
30
- parameters: {
31
- chromatic: { disableSnapshot: true },
32
- },
33
- };
34
-
35
- const meta = {
36
- title: 'Stand/Byline',
37
- component: Byline,
38
- parameters: {},
39
- args: {
40
- handleSave: () => {},
41
- initialValue: [],
42
- searchContributors,
43
- enablePreview: true,
44
- },
45
- } satisfies Meta<typeof Byline>;
46
-
47
- type Story = StoryObj<typeof Byline>;
48
-
49
- export const Default = {} satisfies Story;
50
-
51
- export const WithTheme = {
52
- args: {
53
- allowUntaggedContributors: true,
54
- searchContributors,
55
- theme: {
56
- editor: {
57
- invisibles: {
58
- color: 'lightblue',
59
- },
60
- color: 'rgba(255, 255, 255, 0.87)',
61
- background: 'rgb(51, 51, 51)',
62
- border: '1px solid rgb(173, 216, 230)',
63
- chip: {
64
- color: 'initial',
65
- taggedBackground: 'rgb(173, 216, 230)',
66
- border: '1px solid rgb(173, 216, 230)',
67
- borderRadius: '3px',
68
- padding: '5.5px 7px',
69
- untagged: {
70
- color: 'rgba(255, 255, 255, 0.87)',
71
- },
72
- },
73
- },
74
- dropdown: {
75
- background: 'rgb(36, 36, 36)',
76
- li: {
77
- color: 'rgba(255, 255, 255, 0.87)',
78
- borderBottom: 'none',
79
- selected: {
80
- color: 'rgba(255, 255, 255, 0.87)',
81
- background: 'rgb(51, 51, 51)',
82
- },
83
- },
84
- },
85
- },
86
- },
87
- } satisfies Story;
88
-
89
- export const WithUntaggedContributors = {
90
- args: {
91
- allowUntaggedContributors: true,
92
- },
93
- ...disableSnapshot,
94
- } satisfies Story;
95
-
96
- export const WithInitialValue = {
97
- args: {
98
- allowUntaggedContributors: true,
99
- initialValue: [
100
- {
101
- type: 'contributor',
102
- value: 'Joe Bloggs',
103
- tagId: '1',
104
- path: 'profile/joebloggs',
105
- },
106
- {
107
- type: 'text',
108
- value: ' in London, ',
109
- },
110
- {
111
- type: 'contributor',
112
- value: 'Jane Doe',
113
- },
114
- {
115
- type: 'text',
116
- value: ' in New York',
117
- },
118
- ],
119
- },
120
- } satisfies Story;
121
-
122
- export const WithNoSearch = {
123
- args: {
124
- allowUntaggedContributors: true,
125
- searchContributors: undefined,
126
- },
127
- ...disableSnapshot,
128
- } satisfies Story;
129
-
130
- export const WithNoSearchAndNoUntagged = {
131
- args: {
132
- allowUntaggedContributors: false,
133
- searchContributors: undefined,
134
- },
135
- ...disableSnapshot,
136
- } satisfies Story;
137
-
138
- export const WithCustomPlaceholder = {
139
- args: {
140
- allowUntaggedContributors: true,
141
- placeholder: 'A custom placeholder...',
142
- },
143
- } satisfies Story;
144
-
145
- export const WithContributorLimit = {
146
- args: { contributorLimit: 1 },
147
- ...disableSnapshot,
148
- } satisfies Story;
149
-
150
- export const WithoutPreview = {
151
- args: {
152
- allowUntaggedContributors: true,
153
- enablePreview: false,
154
- },
155
- ...disableSnapshot,
156
- } satisfies Story;
157
-
158
- export const ReadOnly = {
159
- args: {
160
- readOnly: true,
161
- allowUntaggedContributors: true,
162
- enablePreview: true,
163
- initialValue: [
164
- {
165
- type: 'contributor',
166
- value: 'Joe Bloggs',
167
- tagId: '1',
168
- path: 'profile/joebloggs',
169
- },
170
- {
171
- type: 'text',
172
- value: ' in London and ',
173
- },
174
- {
175
- type: 'contributor',
176
- value: 'Jane Doe',
177
- },
178
- {
179
- type: 'text',
180
- value: ' in New York',
181
- },
182
- ],
183
- },
184
- } satisfies Story;
185
-
186
- export default meta;