@alveole/storybook 0.35.3 → 0.36.1
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,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Typography } from '@alveole/components';
|
|
2
|
+
import { ALVEOLE_COMPONENTS_VERSION, Box, Typography } from '@alveole/components';
|
|
3
3
|
import { useTheme } from '@alveole/theme';
|
|
4
4
|
import { Pressable, useWindowDimensions } from 'react-native';
|
|
5
5
|
export const UIKitTopBar = ({ activeKey, items }) => {
|
|
@@ -13,10 +13,10 @@ export const UIKitTopBar = ({ activeKey, items }) => {
|
|
|
13
13
|
alignItems: width >= 960 ? 'center' : 'flex-start',
|
|
14
14
|
flexDirection: width >= 960 ? 'row' : 'column',
|
|
15
15
|
justifyContent: 'space-between',
|
|
16
|
-
}, children: [_jsxs(Box, { display: "flex", gap: 2, children: [_jsx(Typography, { style: text['Corps de texte'].
|
|
16
|
+
}, children: [_jsxs(Box, { display: "flex", gap: 2, children: [_jsx(Typography, { style: text['Corps de texte'].SM.Bold, children: "Alveole \u2022 UI Kit" }), _jsxs(Typography, { style: {
|
|
17
17
|
...text['Corps de texte'].XS.Regular,
|
|
18
18
|
color: color.light.text['mention-grey'],
|
|
19
|
-
}, children: "
|
|
19
|
+
}, children: ["Version ", ALVEOLE_COMPONENTS_VERSION] })] }), _jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: items.map(item => {
|
|
20
20
|
const isActive = item.key === activeKey;
|
|
21
21
|
return (_jsx(Pressable, { accessibilityRole: "link", onPress: item.onPress, children: ({ pressed }) => (_jsx(Box, { borderColor: isActive ? color.light.border['action-low-primary'] : color.light.border['default-grey'], borderRadius: radius('full'), borderWidth: 1, pl: '100', pr: '100', pt: '075', pb: '075', style: {
|
|
22
22
|
backgroundColor: isActive
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryDetailScreen.d.ts","sourceRoot":"","sources":["../../src/screens/StoryDetailScreen.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Button, Page, Section,
|
|
2
|
+
import { Box, Button, Page, Section, Typography } from '@alveole/components';
|
|
3
3
|
import { useTheme } from '@alveole/theme';
|
|
4
|
-
import
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Linking, ScrollView } from 'react-native';
|
|
5
6
|
import { JsonBlock } from '../components/JsonBlock';
|
|
6
7
|
import { getStoryExamples, getStoryFlags } from '../utils';
|
|
7
8
|
const DetailPill = ({ label, tone = 'info' }) => {
|
|
@@ -23,6 +24,27 @@ const MetaCard = ({ label, value }) => {
|
|
|
23
24
|
const { color, radius, text } = useTheme();
|
|
24
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 })] }));
|
|
25
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
|
+
};
|
|
42
|
+
const DetailTabs = ({ tabs, defaultValue }) => {
|
|
43
|
+
const initialValue = defaultValue || tabs[0]?.value || '';
|
|
44
|
+
const [activeValue, setActiveValue] = React.useState(initialValue);
|
|
45
|
+
const activeTab = tabs.find(tab => tab.value === activeValue) ?? tabs[0];
|
|
46
|
+
return (_jsxs(Box, { display: "flex", gap: 16, children: [_jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: tabs.map(tab => (_jsx(Button, { title: tab.label, size: "sm", variant: "tertiary", selected: tab.value === activeTab?.value, onPress: () => setActiveValue(tab.value) }, tab.value))) }), activeTab?.scrollable ? (_jsx(ScrollView, { style: { flex: 1 }, contentContainerStyle: { paddingBottom: 16 }, keyboardShouldPersistTaps: "handled", showsVerticalScrollIndicator: true, children: activeTab.content })) : (activeTab?.content)] }));
|
|
47
|
+
};
|
|
26
48
|
export const StoryDetailScreen = ({ story, notFoundMessage = 'Story not found.', beforeContent, }) => {
|
|
27
49
|
const { text, color, radius } = useTheme();
|
|
28
50
|
if (!story) {
|
|
@@ -32,15 +54,18 @@ export const StoryDetailScreen = ({ story, notFoundMessage = 'Story not found.',
|
|
|
32
54
|
const flags = getStoryFlags(meta);
|
|
33
55
|
const examples = getStoryExamples(story);
|
|
34
56
|
const isTemplate = meta.tags.includes('Template');
|
|
35
|
-
const examplesContent = (_jsx(Box, { display: "flex", gap: 24, mt: '1,5V', children: examples.map(([key, Example]) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}) }));
|
|
39
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: {
|
|
40
65
|
alignItems: 'flex-start',
|
|
41
66
|
flexDirection: 'row',
|
|
42
67
|
justifyContent: 'space-between',
|
|
43
|
-
}, children: [_jsxs(Box, { display: "flex", gap: 6, style: { flex: 1 }, children: [_jsx(Typography, { style: text.Titres['H3 - MD'], children: meta.title }), _jsx(Typography, { style: text['Corps de texte'].MD.Regular, children: meta.description })] }), meta.figmaURL ? (_jsx(Button, { title: "Ouvrir Figma", variant: "primary", onPress: () => Linking.openURL(meta.figmaURL) })) : null] }), _jsxs(Box, { display: "flex", gap: 10, children: [_jsx(Typography, { style: text['Corps de texte'].XS.CapsBold, children: "Tags" }), _jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: meta.tags.map(tag => (_jsx(DetailPill, { label: tag, tone: "tag" }, tag))) })] }), flags.length > 0 ? (_jsxs(Box, { display: "flex", gap: 10, children: [_jsx(Typography, { style: text['Corps de texte'].XS.CapsBold, children: "Informations" }), _jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: flags.map(flag => (_jsx(DetailPill, { label: flag.label }, flag.key))) })] })) : null, _jsxs(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 12, children: [_jsx(MetaCard, { label: "Exemples", value: String(examples.length) }), _jsx(MetaCard, { label: "Styles", value: "Disponibles" }), meta.props != null ? _jsx(MetaCard, { label: "Props", value: "Document\u00E9es" }) : null] })] }), _jsx(
|
|
68
|
+
}, children: [_jsxs(Box, { display: "flex", gap: 6, style: { flex: 1 }, children: [_jsx(Typography, { style: text.Titres['H3 - MD'], children: meta.title }), _jsx(Typography, { style: text['Corps de texte'].MD.Regular, children: meta.description })] }), meta.figmaURL ? (_jsx(Button, { title: "Ouvrir Figma", variant: "primary", onPress: () => Linking.openURL(meta.figmaURL) })) : null] }), _jsxs(Box, { display: "flex", gap: 10, children: [_jsx(Typography, { style: text['Corps de texte'].XS.CapsBold, children: "Tags" }), _jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: meta.tags.map(tag => (_jsx(DetailPill, { label: tag, tone: "tag" }, tag))) })] }), flags.length > 0 ? (_jsxs(Box, { display: "flex", gap: 10, children: [_jsx(Typography, { style: text['Corps de texte'].XS.CapsBold, children: "Informations" }), _jsx(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 8, children: flags.map(flag => (_jsx(DetailPill, { label: flag.label }, flag.key))) })] })) : null, _jsxs(Box, { display: "flex", flexDirection: "row", flexWrap: "wrap", gap: 12, children: [_jsx(MetaCard, { label: "Exemples", value: String(examples.length) }), _jsx(MetaCard, { label: "Styles", value: "Disponibles" }), meta.props != null ? _jsx(MetaCard, { label: "Props", value: "Document\u00E9es" }) : null] })] }), _jsx(DetailTabs, { defaultValue: "examples", tabs: [
|
|
44
69
|
{
|
|
45
70
|
value: 'examples',
|
|
46
71
|
label: 'Examples',
|