@alveole/storybook 0.36.0 → 0.36.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"StoryDetailScreen.d.ts","sourceRoot":"","sources":["../../src/screens/StoryDetailScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC,CAAC;AA8GF,eAAO,MAAM,iBAAiB,GAAI,4CAI/B,sBAAsB,4CAgJxB,CAAC"}
1
+ {"version":3,"file":"StoryDetailScreen.d.ts","sourceRoot":"","sources":["../../src/screens/StoryDetailScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC,CAAC;AAyJF,eAAO,MAAM,iBAAiB,GAAI,4CAI/B,sBAAsB,4CAsJxB,CAAC"}
@@ -24,6 +24,21 @@ const MetaCard = ({ label, value }) => {
24
24
  const { color, radius, text } = useTheme();
25
25
  return (_jsxs(Box, { borderColor: color.light.border['default-grey'], borderRadius: radius('md'), borderWidth: 1, display: "flex", gap: 4, p: '100', style: { backgroundColor: color.light.background['alt-grey'], minWidth: 160 }, children: [_jsx(Typography, { style: text['Corps de texte'].XS.CapsBold, children: label }), _jsx(Typography, { style: text['Corps de texte'].SM.SemiBold, children: value })] }));
26
26
  };
27
+ const getStoryExampleSource = (story, exampleName) => {
28
+ const sources = story.Sources;
29
+ const source = sources?.storySources?.[exampleName] ?? sources?.[exampleName];
30
+ if (typeof source === 'string')
31
+ return source;
32
+ if (typeof source === 'function') {
33
+ const value = source();
34
+ return typeof value === 'string' ? value : null;
35
+ }
36
+ return null;
37
+ };
38
+ const SourceAccordion = ({ source }) => {
39
+ const [isOpen, setIsOpen] = React.useState(false);
40
+ return (_jsxs(Box, { display: "flex", gap: 8, children: [_jsx(Box, { style: { alignItems: 'flex-start' }, children: _jsx(Button, { title: isOpen ? 'Masquer le code source' : 'Afficher le code source', size: "sm", variant: "secondary", endIcon: isOpen ? 'ChevronUp' : 'ChevronDown', onPress: () => setIsOpen(value => !value) }) }), isOpen ? _jsx(JsonBlock, { value: source }) : null] }));
41
+ };
27
42
  const DetailTabs = ({ tabs, defaultValue }) => {
28
43
  const initialValue = defaultValue || tabs[0]?.value || '';
29
44
  const [activeValue, setActiveValue] = React.useState(initialValue);
@@ -39,10 +54,13 @@ export const StoryDetailScreen = ({ story, notFoundMessage = 'Story not found.',
39
54
  const flags = getStoryFlags(meta);
40
55
  const examples = getStoryExamples(story);
41
56
  const isTemplate = meta.tags.includes('Template');
42
- const examplesContent = (_jsx(Box, { display: "flex", gap: 24, mt: '1,5V', children: examples.map(([key, Example]) => (_jsxs(Box, { borderColor: color.light.border['default-grey'], borderRadius: radius('lg'), borderWidth: 1, display: "flex", gap: 16, p: '150', style: { backgroundColor: color.light.background['alt-grey'] }, children: [!isTemplate ? (_jsx(Box, { display: "flex", gap: 6, children: _jsx(Typography, { style: text.Titres['H5 - XS'], children: key }) })) : null, _jsx(Box, { borderColor: color.light.border['default-grey'], borderWidth: 1, borderRadius: radius('md'), p: '100', style: {
43
- backgroundColor: color.light.background['default-grey'],
44
- minHeight: isTemplate ? 420 : undefined,
45
- }, children: _jsx(Example, {}) })] }, key))) }));
57
+ const examplesContent = (_jsx(Box, { display: "flex", gap: 24, mt: '1,5V', children: examples.map(([key, Example]) => {
58
+ const source = getStoryExampleSource(story, key);
59
+ return (_jsxs(Box, { borderColor: color.light.border['default-grey'], borderRadius: radius('lg'), borderWidth: 1, display: "flex", gap: 16, p: '150', style: { backgroundColor: color.light.background['alt-grey'] }, children: [!isTemplate ? (_jsx(Box, { display: "flex", gap: 6, children: _jsx(Typography, { style: text.Titres['H5 - XS'], children: key }) })) : null, _jsx(Box, { borderColor: color.light.border['default-grey'], borderWidth: 1, borderRadius: radius('md'), p: '100', style: {
60
+ backgroundColor: color.light.background['default-grey'],
61
+ minHeight: isTemplate ? 420 : undefined,
62
+ }, children: _jsx(Example, {}) }), source ? _jsx(SourceAccordion, { source: source }) : null] }, key));
63
+ }) }));
46
64
  return (_jsx(Page, { scrollable: true, title: meta.title, description: meta.description, beforeContent: beforeContent, children: _jsx(Section, { withPaddingY: true, children: _jsxs(Box, { display: "flex", gap: 20, children: [_jsxs(Box, { borderColor: color.light.border['default-grey'], borderRadius: radius('lg'), borderWidth: 1, display: "flex", gap: 16, p: '150', style: { backgroundColor: color.light.background['alt-grey'] }, children: [_jsxs(Box, { display: "flex", gap: 12, style: {
47
65
  alignItems: 'flex-start',
48
66
  flexDirection: 'row',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alveole/storybook",
3
- "version": "0.36.0",
3
+ "version": "0.36.2",
4
4
  "description": "Catalog screens and helpers for Alveole stories and theme tokens.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",