scoobie 17.2.2 → 18.0.0

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
@@ -6,76 +6,25 @@
6
6
 
7
7
  Component library for SEEK documentation sites.
8
8
 
9
- - Author content in [Markdown] files
10
- - Diagram with [mermaid] code blocks
11
- - Render content with [Braid] styling
12
- - Integrate with [sku]
13
-
14
9
  We use this to build [developer.seek.com](https://developer.seek.com), among other things.
15
10
 
16
- [braid]: https://github.com/seek-oss/braid-design-system
17
- [markdown]: https://en.wikipedia.org/wiki/Markdown
18
- [mermaid]: https://mermaid-js.github.io/mermaid/#/n00b-overview
19
- [react]: https://reactjs.org/
20
- [sku]: https://github.com/seek-oss/sku
21
-
22
11
  ```shell
23
12
  yarn add --exact scoobie
24
13
  ```
25
14
 
26
- ## Table of contents
27
-
28
- - [Setup](#setup)
29
- - [Markdown reference](#markdown-reference)
30
- - [Getting started](#getting-started)
31
- - [Diagrams](#diagrams)
32
- - [Headings](#headings)
33
- - [Images](#images)
34
- - [Links](#links)
35
- - [Tables](#tables)
36
- - [React API reference](#react-api-reference)
37
- - [Blockquote](#blockquote)
38
- - [CodeBlock](#codeblock)
39
- - [CopyableText](#copyabletext)
40
- - [InlineCode](#inlinecode)
41
- - [InternalLink](#internallink)
42
- - [MdxProvider](#mdxprovider)
43
- - [ScoobieLink](#scoobielink)
44
- - [SmartTextLink](#smarttextlink)
45
- - [Table](#table)
46
- - [TableRow](#tablerow)
47
- - [TocRenderer](#tocrenderer)
48
- - [WrapperRenderer](#wrapperrenderer)
49
- - [Styling reference](#styling-reference)
50
- - [code](#code)
51
- - [img](#img)
52
- - [Webpack reference](#webpack-reference)
53
- - [ScoobieWebpackPlugin](#scoobiewebpackplugin)
54
- - [dangerouslySetWebpackConfig](#dangerouslysetwebpackconfig)
55
- - [merge](#merge)
56
- - [Contributing](https://github.com/seek-oss/scoobie/blob/master/CONTRIBUTING.md)
57
-
58
15
  ## Setup
59
16
 
60
- ### `sku.config.js`
17
+ ### `sku.config.ts`
61
18
 
62
- Compile Scoobie and bundle your Markdown content with its [Webpack plugin]:
63
-
64
- [webpack plugin]: https://webpack.js.org/plugins/
19
+ Compile Scoobie:
65
20
 
66
21
  ```javascript
67
- const { dangerouslySetWebpackConfig } = require('scoobie/webpack');
68
-
69
22
  module.exports = {
70
23
  // ...
71
-
72
24
  compilePackages: ['scoobie'],
73
- dangerouslySetWebpackConfig,
74
25
  };
75
26
  ```
76
27
 
77
- For detailed usage, see the [Webpack reference](#webpack-reference).
78
-
79
28
  ### `src/render.tsx`
80
29
 
81
30
  Fetch our favourite fonts from our Google overlords, Roboto and Roboto Mono:
@@ -105,186 +54,7 @@ Content-Security-Policy: font-src https://fonts.gstatic.com; script-src 'sha256-
105
54
 
106
55
  [content security policy]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
107
56
 
108
- ### `src/scoobie.d.ts`
109
-
110
- Import TypeScript definitions for `MDX`, `*.md` and `*.mdx`:
111
-
112
- ```ts
113
- import 'scoobie/types';
114
- ```
115
-
116
- ## Markdown reference
117
-
118
- ### Getting started
119
-
120
- Scoobie’s Markdown support is powered by [MDX] and custom [Remark plugins].
121
-
122
- [mdx]: https://mdxjs.com/
123
- [remark plugins]: https://github.com/remarkjs/remark/blob/master/doc/plugins.md
124
-
125
- Create your content in `.md` or `.mdx` files:
126
-
127
- ```markdown
128
- # A normal Markdown heading
129
-
130
- Some text...
131
-
132
- import { Alert, Text } from 'braid-design-system';
133
-
134
- <Alert tone="critical"><Text>And a React component!</Text></Alert>
135
- ```
136
-
137
- Import your content into a typical `.tsx` file:
138
-
139
- ```tsx
140
- import React from 'react';
141
-
142
- import Content from './Content.mdx';
143
-
144
- export const ContentWithPointlessDiv = () => (
145
- <div>
146
- <Content />
147
- </div>
148
- );
149
- ```
150
-
151
- Nest your Markdown components within an [MdxProvider](#mdxprovider):
152
-
153
- ```tsx
154
- import 'braid-design-system/reset';
155
-
156
- import { BraidProvider } from 'braid-design-system';
157
- import apacTheme from 'braid-design-system/themes/apac';
158
- import React from 'react';
159
- import { MdxProvider, ScoobieLink } from 'scoobie';
160
-
161
- import { ContentWithPointlessDiv } from './SomeFile.tsx';
162
-
163
- export const App = () => (
164
- <BraidProvider linkComponent={ScoobieLink} theme={apacTheme}>
165
- <MdxProvider>
166
- <ContentWithPointlessDiv />
167
- </MdxProvider>
168
- </BraidProvider>
169
- );
170
- ```
171
-
172
- (See [React context] to learn more about this pattern.)
173
-
174
- [react context]: https://reactjs.org/docs/context.html#contextprovider
175
-
176
- ### Diagrams
177
-
178
- Scoobie optionally supports simple, source-controlled diagrams via [mermaid].
179
-
180
- This requires the `mermaid` configuration option to be set on [ScoobieWebpackPlugin](#scoobiewebpackplugin), and the `mermaid-isomorphic` peer dependency installed.
181
- A playwright installattion of chromium is required, which can be done by installing `playwright` and executing `playwright install chromium`.
182
- From there, the easiest way to get started is to check out the [mermaid live editor].
183
-
184
- You can use a named code block in Markdown files:
185
-
186
- ````markdown
187
- ```mermaid Optional title
188
- sequenceDiagram
189
- autonumber
190
- participant P as Partner
191
- participant S as SEEK
192
-
193
- P->>S: Make request
194
- ```
195
- ````
196
-
197
- Some Mermaid diagrams allow for YAML frontmatter. Scoobie has extended this by allowing a deep merge of the Mermaid configuration
198
- with a special `overrides` key in the frontmatter. This could be useful for diagram-specific configuration that is not otherwise easy to set.
199
-
200
- ````markdown
201
- ```mermaid
202
- ---
203
- overrides:
204
- gantt:
205
- useWidth: 500
206
- ---
207
- gantt
208
- title A Gantt Diagram
209
- dateFormat YYYY-MM-DD
210
- section Section
211
- A task :a1, 2014-01-01, 30d
212
- ```
213
- ````
214
-
215
- [mermaid live editor]: https://mermaidjs.github.io/mermaid-live-editor
216
-
217
- ### Headings
218
-
219
- Anchor slugs are automatically generated for h1–h6:
220
-
221
- ```markdown
222
- # My Little Heading1
223
-
224
- <!-- #my-little-heading1 -->
225
- ```
226
-
227
- ### Images
228
-
229
- Vanilla Markdown image syntax is supported:
230
-
231
- ```markdown
232
- ![Boo raster](./image.png)
233
-
234
- ![Woo vector](./image.svg)
235
- ```
236
-
237
- Define width and height px constraints by overloading the title:
238
-
239
- ```markdown
240
- ![Alt text](./image.png '=100x20 Rest of title')
241
- ```
242
-
243
- ### Links
244
-
245
- Use a root-relative path to navigate to a route managed by your React app.
246
- This will be rendered as a React Router link and won't require a full page refresh.
247
-
248
- Make sure to point to the route rather than the source file location:
249
-
250
- ```markdown
251
- [👍 like this](/root/relative)
252
-
253
- [👎 not this](/src/root/Relative.mdx)
254
- ```
255
-
256
- Use a full URL to denote an external link.
257
- This will open in a new tab.
258
-
259
- ```markdown
260
- [Schema reference](https://developer.seek.com/schema)
261
- ```
262
-
263
- ### Tables
264
-
265
- Standard Markdown table syntax is supported:
266
-
267
- ```markdown
268
- | Default | Left | Centre | Right |
269
- | ------- | :--- | :----: | ----: |
270
- | x | x | x | x |
271
- ```
272
-
273
- Use raw HTML to render multiple lines and lists in table cells.
274
-
275
- Care must be taken with `<p>`s; they are mapped to Braid `Text`s, which have strict semantics.
276
- Paragraph tags must be placed around text content and cannot be nested within each other.
277
-
278
- ```markdown
279
- | Description | Example |
280
- | :---------------------- | :----------------------------------------------------------------- |
281
- | Single-line | Line |
282
- | Multi-line | <p>Line 1</p><p>Line 2</p> |
283
- | Bullets | <ul><li><p>Bullet 1</p></li></ul> |
284
- | Multi-line with bullets | <p>Line before</p><ul><li><p>Bullet</p></li></ul><p>Line after</p> |
285
- ```
286
-
287
- ## React API reference
57
+ ## Components
288
58
 
289
59
  ### Blockquote
290
60
 
@@ -352,9 +122,7 @@ export const MyFirstInlineCode = () => (
352
122
 
353
123
  ### InternalLink
354
124
 
355
- Render an internal link with the same opinions as our [MdxProvider](#mdxprovider):
356
-
357
- - Internal links pass through the `v` or [ScoobieLinkProvider] URL parameters for UI version switching
125
+ Render an internal link. Internal links pass through the `v` or [ScoobieLinkProvider] URL parameters for UI version switching.
358
126
 
359
127
  Unlike [SmartTextLink](#smarttextlink), this is not bound to a parent [Text] as it has no underlying [TextLink].
360
128
  It can be used to make complex components navigable rather than just sections of text.
@@ -379,31 +147,6 @@ export const SomeComplexLinkElement = () => (
379
147
  );
380
148
  ```
381
149
 
382
- ### MdxProvider
383
-
384
- Provide a base collection of [Braid]-styled renderers for child MDX documents.
385
-
386
- This should be paired with [ScoobieLink](#scoobielink) for proper internal link rendering.
387
-
388
- ```tsx
389
- import { BraidProvider, Card } from 'braid-design-system';
390
- import apacTheme from 'braid-design-system/themes/apac';
391
- import React from 'react';
392
- import { MdxProvider, ScoobieLink } from 'scoobie';
393
-
394
- import Content from './Content.mdx';
395
-
396
- export const Component = () => (
397
- <BraidProvider linkComponent={ScoobieLink} theme={apacTheme}>
398
- <MdxProvider>
399
- <Card>
400
- <Content />
401
- </Card>
402
- </MdxProvider>
403
- </BraidProvider>
404
- );
405
- ```
406
-
407
150
  ### ScoobieLink
408
151
 
409
152
  Render all underlying links as follows:
@@ -452,9 +195,7 @@ export const Component = () => (
452
195
 
453
196
  ### SmartTextLink
454
197
 
455
- Render a text link with the same opinions as our [MdxProvider](#mdxprovider):
456
-
457
- - External links open in a new tab and have an [IconNewWindow] suffix
198
+ Render a text link. External links open in a new tab and have an [IconNewWindow] suffix.
458
199
 
459
200
  [iconnewwindow]: https://seek-oss.github.io/braid-design-system/components/IconNewWindow
460
201
 
@@ -478,8 +219,6 @@ export const SomeLinks = () => (
478
219
 
479
220
  ### Table
480
221
 
481
- Render an HTML table with the same styling as our [MdxProvider](#mdxprovider):
482
-
483
222
  ```tsx
484
223
  import React, { Fragment } from 'react';
485
224
  import { Table, TableRow } from 'scoobie';
@@ -505,77 +244,6 @@ export const MyFirstTable = () => (
505
244
 
506
245
  Row children are flattened then wrapped with `<td>`s.
507
246
 
508
- ### TocRenderer
509
-
510
- Render headings from an MDX document with a custom function.
511
-
512
- ```tsx
513
- import { Stack, TextLink } from 'braid-design-system';
514
- import React from 'react';
515
- import { TocRenderer } from 'scoobie';
516
-
517
- import Content from './Content.mdx';
518
-
519
- export const PageWithToc = () => (
520
- <Stack space="medium">
521
- <TocRenderer document={Content}>
522
- {(toc) => (
523
- <Text>
524
- <Stack space="small">
525
- {toc.map((item) => (
526
- <TextLink href={`#${item.id}`} key={item.id}>
527
- {'|'.repeat(item.level)} {item.children}
528
- </TextLink>
529
- ))}
530
- </Stack>
531
- </Text>
532
- )}
533
- </TocRenderer>
534
-
535
- <Content />
536
- </Stack>
537
- );
538
- ```
539
-
540
- A heading must start at the beginning of its line to be parsed:
541
-
542
- ```markdown
543
- # Good
544
-
545
- - ## Bad
546
-
547
- - ### Super bad
548
-
549
- ## Good again
550
- ```
551
-
552
- (This can be enforced with [markdownlint]’s [MD023] rule.)
553
-
554
- [markdownlint]: https://github.com/markdownlint/markdownlint
555
- [md023]: https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md023---headers-must-start-at-the-beginning-of-the-line
556
-
557
- ### WrapperRenderer
558
-
559
- Render an MDX document with a [customised wrapper].
560
-
561
- [customised wrapper]: https://mdxjs.com/guides/wrapper-customization
562
-
563
- This allows you to derive arbitrary components from select parts of the document.
564
-
565
- ```tsx
566
- import { Text } from 'braid-design-system';
567
- import React, { Children } from 'react';
568
- import { WrapperRenderer } from 'scoobie';
569
-
570
- export const NodeCount = (Document: MDX.Document) => (
571
- <WrapperRenderer document={Document}>
572
- {({ children }) => (
573
- <Text>{Children.toArray(children).length} top-level node(s)</Text>
574
- )}
575
- </WrapperRenderer>
576
- );
577
- ```
578
-
579
247
  ## Styling reference
580
248
 
581
249
  Scoobie distributes some vanilla-extract styles via `scoobie/styles` submodules.
@@ -598,8 +266,6 @@ export const MyBox = () => (
598
266
 
599
267
  ### img
600
268
 
601
- Render an image with the same styling as our [MdxProvider](#mdxprovider):
602
-
603
269
  ```tsx
604
270
  import React from 'react';
605
271
  import { img } from 'scoobie/styles/img.css';
@@ -624,46 +290,3 @@ Compatibility notes:
624
290
  - SVGs cannot be directly imported into JSX as components.
625
291
 
626
292
  Consider inlining the SVGs in your JSX instead.
627
-
628
- ### ScoobieWebpackPlugin
629
-
630
- A bundle of MDX and image loaders that complement sku's Webpack config.
631
-
632
- This needs to be ordered to run after SkuWebpackPlugin:
633
-
634
- ```javascript
635
- const { ScoobieWebpackPlugin, merge } = require('scoobie/webpack');
636
-
637
- module.exports = {
638
- // ...
639
-
640
- compilePackages: ['scoobie'],
641
- dangerouslySetWebpackConfig: (config) =>
642
- merge(config, {
643
- plugins: [
644
- new ScoobieWebpackPlugin({
645
- // Optional configuration option to enable mermaid support.
646
- // `@mermaid-js/mermaid-cli` must be installed as a peer dependency.
647
- // Temporary files are written to `${rootDir}/mermaid`.
648
- mermaid: {
649
- rootDir: __dirname,
650
- },
651
- }),
652
- ],
653
- }),
654
- };
655
- ```
656
-
657
- ### dangerouslySetWebpackConfig
658
-
659
- Zero-config option referenced in [sku.config.js](#skuconfigjs) above.
660
-
661
- This slots in on top of sku without much fuss.
662
- If you're wrangling other Webpack config and need something more composable,
663
- see [ScoobieWebpackPlugin](#scoobiewebpackplugin).
664
-
665
- ### merge
666
-
667
- Re-export of [webpack-merge] for convenience.
668
-
669
- [webpack-merge]: https://github.com/survivejs/webpack-merge
package/package.json CHANGED
@@ -4,36 +4,22 @@
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "sideEffects": false,
7
- "version": "17.2.2",
7
+ "version": "18.0.0",
8
8
  "dependencies": {
9
9
  "@capsizecss/core": "^4.0.0",
10
- "@mdx-js/react": "^1.6.22",
11
- "@types/mdx-js__react": "^1.5.5",
12
10
  "@vanilla-extract/css": "^1.2.3",
13
11
  "@vanilla-extract/css-utils": "^0.1.1",
14
- "babel-loader": "^9.0.0",
15
12
  "clsx": "^2.0.0",
16
- "deepmerge-ts": "^7.1.0",
17
- "find-up": "^5.0.0",
18
- "fs-extra": "^11.0.0",
19
13
  "jsonc-parser": "^3.0.0",
20
14
  "polished": "^4.1.3",
21
15
  "prism-react-renderer": "2.4.0",
22
16
  "react-keyed-flatten-children": "^3.0.0",
23
17
  "refractor": "^3.4.0",
24
- "remark-slug": "^6.1.0",
25
- "svgo": "^3.0.0",
26
- "svgo-loader": "^4.0.0",
27
- "unist-util-visit": "^2.0.3",
28
- "unist-util-visit-parents": "^3.1.1",
29
- "webpack-merge": "^6.0.0",
30
- "which": "^4.0.0",
31
- "yaml": "^2.5.0"
18
+ "remark-slug": "^6.1.0"
32
19
  },
33
20
  "devDependencies": {
34
21
  "@changesets/cli": "2.27.8",
35
22
  "@changesets/get-github-info": "0.6.0",
36
- "@mdx-js/loader": "^1.6.22",
37
23
  "@storybook/addon-essentials": "8.3.2",
38
24
  "@storybook/addon-webpack5-compiler-babel": "3.0.3",
39
25
  "@storybook/react": "8.3.2",
@@ -42,8 +28,6 @@
42
28
  "@types/react-dom": "18.3.0",
43
29
  "braid-design-system": "32.24.1",
44
30
  "loki": "0.35.1",
45
- "mermaid-isomorphic": "2.2.1",
46
- "playwright": "1.47.2",
47
31
  "react": "18.3.1",
48
32
  "react-dom": "18.3.1",
49
33
  "react-helmet-async": "1.3.0",
@@ -61,21 +45,11 @@
61
45
  "typography.ts"
62
46
  ],
63
47
  "peerDependencies": {
64
- "@mdx-js/loader": "^1.6.22",
65
48
  "braid-design-system": ">= 31.21.0",
66
- "mermaid-isomorphic": "^2.2.1",
67
49
  "react": ">= 17 < 19",
68
50
  "react-router-dom": ">= 5.3.0",
69
51
  "sku": ">= 13.0.0 < 14"
70
52
  },
71
- "peerDependenciesMeta": {
72
- "@mdx-js/loader": {
73
- "optional": true
74
- },
75
- "mermaid-isomorphic": {
76
- "optional": true
77
- }
78
- },
79
53
  "repository": {
80
54
  "type": "git",
81
55
  "url": "https://github.com/seek-oss/scoobie.git"
@@ -91,8 +65,7 @@
91
65
  "storybook:build": "storybook build --output-dir dist-storybook",
92
66
  "storybook:start": "storybook dev",
93
67
  "test": "sku test",
94
- "test:ci": "sku test --coverage",
95
- "prepare": "playwright install chromium"
68
+ "test:ci": "sku test --coverage"
96
69
  },
97
70
  "loki": {
98
71
  "configurations": {
package/src/index.ts CHANGED
@@ -3,13 +3,8 @@ export { CodeBlock } from './components/CodeBlock';
3
3
  export { CopyableText } from './components/CopyableText';
4
4
  export { InlineCode } from './components/InlineCode';
5
5
  export { InternalLink } from './components/InternalLink';
6
- export { MdxProvider } from './components/MdxProvider';
7
6
  export { ScoobieLink } from './components/ScoobieLink';
8
7
  export { ScoobieLinkProvider } from './components/ScoobieLinkProvider';
9
8
  export { SmartTextLink } from './components/SmartTextLink';
10
9
  export { Table } from './components/Table';
11
10
  export { TableRow } from './components/TableRow';
12
- export { TocRenderer } from './components/TocRenderer';
13
- export { WrapperRenderer } from './components/WrapperRenderer';
14
-
15
- export type { Toc, TocItem } from './components/TocRenderer';
@@ -2,13 +2,6 @@ import { Box } from 'braid-design-system';
2
2
  import React, { Fragment, type ReactNode } from 'react';
3
3
 
4
4
  import { ScrollableInline } from './ScrollableInline';
5
- import {
6
- DEFAULT_TABLE_CELL_COMPONENT,
7
- DEFAULT_TABLE_TYPE,
8
- TableContext,
9
- type TableType,
10
- } from './TableContext';
11
- import { DEFAULT_SIZE, type Size } from './size';
12
5
 
13
6
  import * as styles from './Table.css';
14
7
 
@@ -41,27 +34,3 @@ export const BaseTable = ({
41
34
  </Wrapper>
42
35
  );
43
36
  };
44
-
45
- interface MdxTableProps {
46
- children: ReactNode;
47
- size?: Size;
48
- type?: TableType;
49
- }
50
-
51
- export const MdxTable = ({
52
- children,
53
- size = DEFAULT_SIZE,
54
- type = DEFAULT_TABLE_TYPE,
55
- }: MdxTableProps) => (
56
- <TableContext.Provider
57
- value={{
58
- component: DEFAULT_TABLE_CELL_COMPONENT,
59
- size,
60
- type,
61
- }}
62
- >
63
- <BaseTable overflowX="scroll" width="full">
64
- {children}
65
- </BaseTable>
66
- </TableContext.Provider>
67
- );
@@ -3,10 +3,4 @@ import type { ComponentProps } from 'react';
3
3
 
4
4
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
5
5
 
6
- export interface MdxElement {
7
- props: {
8
- mdxType: string;
9
- };
10
- }
11
-
12
6
  export type StackChildrenProps = Pick<ComponentProps<typeof Stack>, 'children'>;
@@ -1,43 +0,0 @@
1
- const visit = require('unist-util-visit');
2
-
3
- const containsParagraphNode = (node) =>
4
- (node.type === 'jsx' &&
5
- typeof node.value === 'string' &&
6
- node.value.toLocaleLowerCase().trim().replace(/[\s/]/g, '') === '<p>') ||
7
- (Array.isArray(node.children) && node.children.some(containsParagraphNode));
8
-
9
- /**
10
- * Apply default formatting to table cells for improved rendering in a Braid
11
- * context:
12
- *
13
- * - Wrap cell in a `<strong>` if it is a header cell
14
- * - Wrap cell in a `<p>`
15
- *
16
- * This can be disabled by using an explicit `<p>` tag in the cell.
17
- */
18
- module.exports.formatTableCells = () => (tree) =>
19
- visit(tree, 'table', (node) =>
20
- node.children.forEach((row, rowIndex) =>
21
- row.children.forEach((cell) => {
22
- if (containsParagraphNode(cell)) {
23
- return;
24
- }
25
-
26
- if (rowIndex === 0) {
27
- cell.children = [
28
- {
29
- children: cell.children,
30
- type: 'strong',
31
- },
32
- ];
33
- }
34
-
35
- cell.children = [
36
- {
37
- children: cell.children,
38
- type: 'paragraph',
39
- },
40
- ];
41
- }),
42
- ),
43
- );