Skip to content

Commit 9141ffa

Browse files
committed
chore: move Icon docs and fix faceted-search
1 parent 018faaf commit 9141ffa

File tree

11 files changed

+290
-72
lines changed

11 files changed

+290
-72
lines changed

.surge/index.html

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,30 +187,10 @@ <h2 class="card__heading">Icons</h2>
187187
</div>
188188

189189
<div class="card">
190-
<a href="design-system" class="card__link">
191-
<h2 class="card__heading">Coral</h2>
192-
<p class="card__body">Talend's Design system documentation and React library</p>
190+
<a href="storybook-one" class="card__link">
191+
<h2 class="card__heading">Storybook</h2>
192+
<p class="card__body">All the stories of all the packages</p>
193193
</a>
194-
<a
195-
class="card__link--with-arrow"
196-
href="/@talend/design-system/dist/TalendDesignSystem.js.report.html"
197-
>UMD
198-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 10">
199-
<path
200-
fill="currentColor"
201-
d="M5.586.625l-.965.957 2.758 2.734H0v1.368h7.38L4.62 8.418l.966.957L10 4.999 5.586.625z"
202-
/></svg
203-
></a>
204-
<a
205-
class="card__link--with-arrow"
206-
href="/@talend/design-system/dist/TalendDesignSystem.min.js.report.html"
207-
>Minified UMD
208-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 10">
209-
<path
210-
fill="currentColor"
211-
d="M5.586.625l-.965.957 2.758 2.734H0v1.368h7.38L4.62 8.418l.966.957L10 4.999 5.586.625z"
212-
/></svg
213-
></a>
214194
</div>
215195

216196
<div class="card">
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
import { useState, useCallback } from 'react';
2+
import { within, userEvent } from '@storybook/testing-library';
3+
import { action } from '@storybook/addon-actions';
4+
import { Badge } from '@talend/react-components';
5+
import { useTranslation } from 'react-i18next';
6+
import set from 'lodash/set';
7+
import cloneDeep from 'lodash/cloneDeep';
8+
import times from 'lodash/times';
9+
10+
import FacetedSearch from '../src';
11+
import { BadgeFacetedProvider } from '../src/components/context/badgeFaceted.context';
12+
import { BadgesGenerator } from '../src/components/BadgesGenerator';
13+
import { createBadgesDict, getBadgesFromDict } from '../src/dictionary/badge.dictionary';
14+
15+
import {
16+
badgeConnectionType,
17+
badgeName,
18+
badgeConnectionName,
19+
badgeAuthor,
20+
badgeAll,
21+
badgePrice,
22+
badgeValid,
23+
badgeEmpty,
24+
badgeInvalid,
25+
badgeTags,
26+
badgeCreationDate,
27+
badgeWithVeryLongName,
28+
badgeEnumWithLotOfValues,
29+
badgeTextAsCategory,
30+
badgeTextAsCustomAttribute,
31+
badgeEnumsAsCustomAttribute,
32+
badgePriceAsCustomAttribute,
33+
badgeEmptyLabel,
34+
badgeConnectionTypeAllSelector,
35+
} from './badgesDefinitions';
36+
37+
const badgesDefinitions = [
38+
badgeAll,
39+
badgeName,
40+
badgeConnectionName,
41+
badgeAuthor,
42+
badgeConnectionType,
43+
badgeTags,
44+
badgePrice,
45+
badgeValid,
46+
badgeEmpty,
47+
badgeInvalid,
48+
badgeCreationDate,
49+
];
50+
51+
const callbacks = {
52+
getTags: () =>
53+
new Promise(resolve =>
54+
setTimeout(resolve, 2000, [
55+
'clean',
56+
'production',
57+
'last chunk',
58+
'salesforce',
59+
'outdated',
60+
'extracted',
61+
'security',
62+
'in processing',
63+
'deep learning',
64+
'sql',
65+
'cluster',
66+
'visualization',
67+
'analytics',
68+
'users',
69+
'warehouse',
70+
'api',
71+
]),
72+
),
73+
};
74+
75+
const badgesFaceted = {
76+
badges: [
77+
{
78+
properties: {
79+
attribute: 'connection.type',
80+
initialOperatorOpened: false,
81+
initialValueOpened: false,
82+
label: 'Connection Type',
83+
operator: {
84+
label: 'In',
85+
name: 'in',
86+
},
87+
operators: [
88+
{
89+
label: 'In',
90+
name: 'in',
91+
},
92+
],
93+
type: 'checkbox',
94+
value: [
95+
{
96+
id: 'amazon_s3',
97+
label: 'Amazon S3',
98+
checked: true,
99+
},
100+
{
101+
id: 'hdfs',
102+
label: 'HDFS',
103+
checked: true,
104+
},
105+
{
106+
id: 'localcon',
107+
label: 'Local connection',
108+
checked: true,
109+
},
110+
],
111+
},
112+
metadata: {
113+
badgePerFacet: '1',
114+
entitiesPerBadge: 'N',
115+
values: [
116+
{ id: 'amazon_s3', label: 'Amazon S3' },
117+
{ id: 'hdfs', label: 'HDFS' },
118+
{ id: 'kafka', label: 'Kafka' },
119+
{ id: 'localcon', label: 'Local connection' },
120+
{ id: 'salesforce', label: 'Salesforce' },
121+
{ id: 'aws_kinesis', label: 'AWS kinesis' },
122+
],
123+
operators: ['in'],
124+
badgeId: 'connection.type-9f0e5bc7-c687-4198-9635-d0fc7724dfd1',
125+
isInCreation: false,
126+
},
127+
},
128+
],
129+
};
130+
131+
const badgesWithAll = {
132+
badges: [
133+
{
134+
properties: {
135+
attribute: 'all',
136+
initialOperatorOpened: false,
137+
initialValueOpened: false,
138+
label: 'All',
139+
operator: { label: 'Contains', name: 'containsIgnoreCase', iconName: 'contains' },
140+
operators: [],
141+
type: 'text',
142+
value: 'test',
143+
},
144+
metadata: {
145+
isAvailableForFacetList: false,
146+
badgePerFacet: 'N',
147+
entitiesPerBadge: '1',
148+
operators: ['containsIgnoreCase'],
149+
badgeId: 'all-b6c04e3d-1d72-4aca-9565-09d206f76d88',
150+
isInCreation: false,
151+
},
152+
},
153+
],
154+
};
155+
156+
export default {
157+
title: 'Faceted search/Badge',
158+
component: FacetedSearch.Faceted,
159+
parameters: {
160+
docs: {
161+
description: {
162+
component:
163+
'Faceted search is a technique that involves augmenting traditional search techniques with a faceted navigation system, allowing users to narrow down search results by applying multiple filters based on faceted classification of the items. The user can look for any value, even if the field is not currently visible.',
164+
},
165+
},
166+
},
167+
decorators: [
168+
(Story, context) => (
169+
<div>
170+
<Story {...context} />
171+
</div>
172+
),
173+
],
174+
};
175+
176+
export const WithSpecialChars = () => {
177+
const { t } = useTranslation();
178+
const badgesDictionary = createBadgesDict();
179+
const badge = cloneDeep(badgesFaceted.badges[0]);
180+
Object.assign(badge.properties, {
181+
value: ' text ',
182+
type: 'text',
183+
displayType: Badge.TYPES.PATTERN,
184+
});
185+
return (
186+
<BadgeFacetedProvider value={{}}>
187+
<BadgesGenerator
188+
badges={[badge]}
189+
badgesDictionary={badgesDictionary}
190+
getBadgeFromDict={getBadgesFromDict}
191+
t={t}
192+
/>
193+
</BadgeFacetedProvider>
194+
);
195+
};
196+
197+
export const DatePicker = () => {
198+
const { t } = useTranslation();
199+
const badgesDictionary = createBadgesDict();
200+
const badge = cloneDeep(badgesFaceted.badges[0]);
201+
Object.assign(badge.properties, {
202+
value: Date.now(),
203+
type: 'date',
204+
});
205+
return (
206+
<BadgeFacetedProvider value={{}}>
207+
<BadgesGenerator
208+
badges={[badge]}
209+
badgesDictionary={badgesDictionary}
210+
getBadgeFromDict={getBadgesFromDict}
211+
t={t}
212+
/>
213+
</BadgeFacetedProvider>
214+
);
215+
};
216+
217+
export const ReadOnly = () => {
218+
const { t } = useTranslation();
219+
const badgesDictionary = createBadgesDict();
220+
return (
221+
<BadgeFacetedProvider value={{}}>
222+
<BadgesGenerator
223+
badges={[
224+
set(cloneDeep(badgesFaceted.badges[0]), 'properties.readOnly', true),
225+
set(cloneDeep(badgesFaceted.badges[0]), 'properties.removable', false),
226+
]}
227+
badgesDictionary={badgesDictionary}
228+
getBadgeFromDict={getBadgesFromDict}
229+
t={t}
230+
/>
231+
</BadgeFacetedProvider>
232+
);
233+
};

packages/faceted-search/stories/facetedSearch.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const badgesWithAll = {
154154
};
155155

156156
export default {
157-
title: 'Faceted search',
157+
title: 'Faceted search/Main',
158158
component: FacetedSearch.Faceted,
159159
parameters: {
160160
docs: {

packages/icons/stories/DeprecatedIcon.stories.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/icons/stories/DeprecatedIcons.stories.mdx

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Icon from './Icon';
2+
import { info as icons } from '../dist/info';
3+
4+
export default {
5+
title: 'Icons/Icon',
6+
component: Icon,
7+
};
8+
9+
export const Usage = {
10+
args: {
11+
name: 'talend-box',
12+
},
13+
argTypes: {
14+
name: {
15+
options: Object.keys(icons),
16+
control: {
17+
type: 'select',
18+
},
19+
},
20+
},
21+
};
22+
23+
export const All = props => {
24+
const names = Object.keys(icons);
25+
return (
26+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
27+
{names.map(name => (
28+
<div
29+
key={name}
30+
style={{
31+
display: 'flex',
32+
flexDirection: 'column',
33+
alignItems: 'center',
34+
margin: '1rem',
35+
}}
36+
>
37+
<Icon name={name} />
38+
<span style={{ fontSize: '2rem' }}>{name}</span>
39+
</div>
40+
))}
41+
</div>
42+
);
43+
};

packages/storybook-one/.storybook/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ const STORIES = [
1919
`${rootPath}../forms/**/*.stories.@(js|tsx)`,
2020
`${rootPath}../dataviz/src/**/*.stories.@(js|tsx)`,
2121
`${rootPath}../icons/stories/**/*.stories.@(js|tsx)`,
22+
`${rootPath}../faceted-search/stories/**/*.stories.@(js|tsx)`,
2223
];
2324

2425
const monoRepoFixSourceMap = [
25-
'../design-system/src',
2626
'../components/src',
2727
'../dataviz/src',
28+
'../design-system/src',
29+
'../faceted-search/stories',
30+
'../faceted-search/src',
2831
'../forms/src',
2932
'../forms/stories',
3033
'../icons/stories',

packages/storybook-one/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"extends": "@talend/scripts-config-typescript/tsconfig.json",
3-
"include": ["src/**/*", "../components/src/**/*", "../forms/src/**/*"],
3+
"include": [
4+
"src/**/*",
5+
"../components/src/**/*",
6+
"../forms/src/**/*",
7+
"../faceted-search/src/**/*"
8+
],
49
"compilerOptions": {
510
"baseUrl": ".",
611
"module": "CommonJs",

0 commit comments

Comments
 (0)