scoobie 18.1.2 → 18.2.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/package.json +11 -11
- package/src/components/CodeBlock.tsx +52 -35
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "18.
|
|
7
|
+
"version": "18.2.0",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@capsizecss/core": "^4.0.0",
|
|
10
10
|
"@vanilla-extract/css": "^1.2.3",
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
"refractor": "^3.4.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@changesets/cli": "2.27.
|
|
20
|
+
"@changesets/cli": "2.27.11",
|
|
21
21
|
"@changesets/get-github-info": "0.6.0",
|
|
22
|
-
"@storybook/addon-essentials": "8.4.
|
|
22
|
+
"@storybook/addon-essentials": "8.4.7",
|
|
23
23
|
"@storybook/addon-webpack5-compiler-babel": "3.0.3",
|
|
24
|
-
"@storybook/react": "8.4.
|
|
25
|
-
"@storybook/react-webpack5": "8.4.
|
|
26
|
-
"@types/react": "18.3.
|
|
27
|
-
"@types/react-dom": "18.3.
|
|
28
|
-
"braid-design-system": "33.
|
|
24
|
+
"@storybook/react": "8.4.7",
|
|
25
|
+
"@storybook/react-webpack5": "8.4.7",
|
|
26
|
+
"@types/react": "18.3.16",
|
|
27
|
+
"@types/react-dom": "18.3.5",
|
|
28
|
+
"braid-design-system": "33.3.0",
|
|
29
29
|
"loki": "0.35.1",
|
|
30
30
|
"react": "18.3.1",
|
|
31
31
|
"react-dom": "18.3.1",
|
|
32
32
|
"react-helmet-async": "2.0.5",
|
|
33
|
-
"react-router-dom": "
|
|
33
|
+
"react-router-dom": "7.1.1",
|
|
34
34
|
"sku": "13.3.0",
|
|
35
|
-
"storybook": "8.4.
|
|
36
|
-
"webpack": "5.
|
|
35
|
+
"storybook": "8.4.7",
|
|
36
|
+
"webpack": "5.97.1"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"src",
|
|
@@ -28,6 +28,8 @@ interface Props {
|
|
|
28
28
|
language?: string;
|
|
29
29
|
size?: Size;
|
|
30
30
|
trim?: boolean;
|
|
31
|
+
lineNumbers?: boolean;
|
|
32
|
+
copy?: boolean;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export const CodeBlock = ({
|
|
@@ -38,6 +40,8 @@ export const CodeBlock = ({
|
|
|
38
40
|
language: rawLanguage,
|
|
39
41
|
size = DEFAULT_SIZE,
|
|
40
42
|
trim = true,
|
|
43
|
+
lineNumbers = true,
|
|
44
|
+
copy = true,
|
|
41
45
|
}: Props) => {
|
|
42
46
|
const children = normaliseChildren(
|
|
43
47
|
typeof rawChildren === 'string'
|
|
@@ -90,47 +94,58 @@ export const CodeBlock = ({
|
|
|
90
94
|
</Box>
|
|
91
95
|
) : undefined;
|
|
92
96
|
|
|
97
|
+
const topRow =
|
|
98
|
+
children.some(({ label }) => label) || copy || graphqlPlaygroundButton;
|
|
99
|
+
|
|
93
100
|
return (
|
|
94
101
|
<Stack space={tablePadding}>
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
<Box display="flex">
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
label
|
|
111
|
-
) : (
|
|
112
|
-
<TextLinkButton
|
|
113
|
-
onClick={() =>
|
|
114
|
-
setIndex({ dirty: true, value: labelIndex })
|
|
102
|
+
{topRow ? (
|
|
103
|
+
<ScrollableInline whiteSpace="nowrap">
|
|
104
|
+
<Box display="flex" justifyContent="spaceBetween">
|
|
105
|
+
<Box display="flex">
|
|
106
|
+
{children.map(({ label }, labelIndex) =>
|
|
107
|
+
label ? (
|
|
108
|
+
<Box
|
|
109
|
+
component="span"
|
|
110
|
+
key={label}
|
|
111
|
+
paddingLeft={labelIndex === 0 ? undefined : tablePadding}
|
|
112
|
+
>
|
|
113
|
+
<Text
|
|
114
|
+
size={smallerSize}
|
|
115
|
+
tone={
|
|
116
|
+
index.value === labelIndex ? 'secondary' : undefined
|
|
115
117
|
}
|
|
118
|
+
weight="medium"
|
|
116
119
|
>
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
{children.length === 1 || index.value === labelIndex ? (
|
|
121
|
+
label
|
|
122
|
+
) : (
|
|
123
|
+
<TextLinkButton
|
|
124
|
+
onClick={() =>
|
|
125
|
+
setIndex({ dirty: true, value: labelIndex })
|
|
126
|
+
}
|
|
127
|
+
>
|
|
128
|
+
{label}
|
|
129
|
+
</TextLinkButton>
|
|
130
|
+
)}
|
|
131
|
+
</Text>
|
|
132
|
+
</Box>
|
|
133
|
+
) : null,
|
|
134
|
+
)}
|
|
128
135
|
</Box>
|
|
129
136
|
|
|
130
|
-
|
|
137
|
+
<Box display="flex">
|
|
138
|
+
{copy ? (
|
|
139
|
+
<Box component="span" paddingLeft={tablePadding}>
|
|
140
|
+
<CopyableText size={smallerSize}>{child.code}</CopyableText>
|
|
141
|
+
</Box>
|
|
142
|
+
) : null}
|
|
143
|
+
|
|
144
|
+
{graphqlPlaygroundButton}
|
|
145
|
+
</Box>
|
|
131
146
|
</Box>
|
|
132
|
-
</
|
|
133
|
-
|
|
147
|
+
</ScrollableInline>
|
|
148
|
+
) : null}
|
|
134
149
|
|
|
135
150
|
<Box borderRadius="large" className={styles.codeContainer}>
|
|
136
151
|
<Highlight
|
|
@@ -141,7 +156,9 @@ export const CodeBlock = ({
|
|
|
141
156
|
>
|
|
142
157
|
{({ getTokenProps, tokens }) => (
|
|
143
158
|
<Box display="flex">
|
|
144
|
-
|
|
159
|
+
{lineNumbers ? (
|
|
160
|
+
<LineNumbers count={tokens.length} size={size} />
|
|
161
|
+
) : null}
|
|
145
162
|
|
|
146
163
|
<Lines getTokenProps={getTokenProps} lines={tokens} size={size} />
|
|
147
164
|
</Box>
|