Skip to content

Commit

Permalink
chore: move Icon docs and fix faceted-search
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois committed Sep 11, 2023
1 parent 018faaf commit 9141ffa
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 72 deletions.
26 changes: 3 additions & 23 deletions .surge/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,10 @@ <h2 class="card__heading">Icons</h2>
</div>

<div class="card">
<a href="design-system" class="card__link">
<h2 class="card__heading">Coral</h2>
<p class="card__body">Talend's Design system documentation and React library</p>
<a href="storybook-one" class="card__link">
<h2 class="card__heading">Storybook</h2>
<p class="card__body">All the stories of all the packages</p>
</a>
<a
class="card__link--with-arrow"
href="/@talend/design-system/dist/TalendDesignSystem.js.report.html"
>UMD
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 10">
<path
fill="currentColor"
d="M5.586.625l-.965.957 2.758 2.734H0v1.368h7.38L4.62 8.418l.966.957L10 4.999 5.586.625z"
/></svg
></a>
<a
class="card__link--with-arrow"
href="/@talend/design-system/dist/TalendDesignSystem.min.js.report.html"
>Minified UMD
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 10">
<path
fill="currentColor"
d="M5.586.625l-.965.957 2.758 2.734H0v1.368h7.38L4.62 8.418l.966.957L10 4.999 5.586.625z"
/></svg
></a>
</div>

<div class="card">
Expand Down
233 changes: 233 additions & 0 deletions packages/faceted-search/stories/badge.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import { useState, useCallback } from 'react';
import { within, userEvent } from '@storybook/testing-library';
import { action } from '@storybook/addon-actions';
import { Badge } from '@talend/react-components';
import { useTranslation } from 'react-i18next';
import set from 'lodash/set';
import cloneDeep from 'lodash/cloneDeep';
import times from 'lodash/times';

import FacetedSearch from '../src';
import { BadgeFacetedProvider } from '../src/components/context/badgeFaceted.context';
import { BadgesGenerator } from '../src/components/BadgesGenerator';
import { createBadgesDict, getBadgesFromDict } from '../src/dictionary/badge.dictionary';

import {
badgeConnectionType,
badgeName,
badgeConnectionName,
badgeAuthor,
badgeAll,
badgePrice,
badgeValid,
badgeEmpty,
badgeInvalid,
badgeTags,
badgeCreationDate,
badgeWithVeryLongName,
badgeEnumWithLotOfValues,
badgeTextAsCategory,
badgeTextAsCustomAttribute,
badgeEnumsAsCustomAttribute,
badgePriceAsCustomAttribute,
badgeEmptyLabel,
badgeConnectionTypeAllSelector,
} from './badgesDefinitions';

const badgesDefinitions = [
badgeAll,
badgeName,
badgeConnectionName,
badgeAuthor,
badgeConnectionType,
badgeTags,
badgePrice,
badgeValid,
badgeEmpty,
badgeInvalid,
badgeCreationDate,
];

const callbacks = {
getTags: () =>
new Promise(resolve =>
setTimeout(resolve, 2000, [
'clean',
'production',
'last chunk',
'salesforce',
'outdated',
'extracted',
'security',
'in processing',
'deep learning',
'sql',
'cluster',
'visualization',
'analytics',
'users',
'warehouse',
'api',
]),
),
};

const badgesFaceted = {
badges: [
{
properties: {
attribute: 'connection.type',
initialOperatorOpened: false,
initialValueOpened: false,
label: 'Connection Type',
operator: {
label: 'In',
name: 'in',
},
operators: [
{
label: 'In',
name: 'in',
},
],
type: 'checkbox',
value: [
{
id: 'amazon_s3',
label: 'Amazon S3',
checked: true,
},
{
id: 'hdfs',
label: 'HDFS',
checked: true,
},
{
id: 'localcon',
label: 'Local connection',
checked: true,
},
],
},
metadata: {
badgePerFacet: '1',
entitiesPerBadge: 'N',
values: [
{ id: 'amazon_s3', label: 'Amazon S3' },
{ id: 'hdfs', label: 'HDFS' },
{ id: 'kafka', label: 'Kafka' },
{ id: 'localcon', label: 'Local connection' },
{ id: 'salesforce', label: 'Salesforce' },
{ id: 'aws_kinesis', label: 'AWS kinesis' },
],
operators: ['in'],
badgeId: 'connection.type-9f0e5bc7-c687-4198-9635-d0fc7724dfd1',
isInCreation: false,
},
},
],
};

const badgesWithAll = {
badges: [
{
properties: {
attribute: 'all',
initialOperatorOpened: false,
initialValueOpened: false,
label: 'All',
operator: { label: 'Contains', name: 'containsIgnoreCase', iconName: 'contains' },
operators: [],
type: 'text',
value: 'test',
},
metadata: {
isAvailableForFacetList: false,
badgePerFacet: 'N',
entitiesPerBadge: '1',
operators: ['containsIgnoreCase'],
badgeId: 'all-b6c04e3d-1d72-4aca-9565-09d206f76d88',
isInCreation: false,
},
},
],
};

export default {
title: 'Faceted search/Badge',
component: FacetedSearch.Faceted,
parameters: {
docs: {
description: {
component:
'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.',
},
},
},
decorators: [
(Story, context) => (
<div>
<Story {...context} />
</div>
),
],
};

export const WithSpecialChars = () => {
const { t } = useTranslation();
const badgesDictionary = createBadgesDict();
const badge = cloneDeep(badgesFaceted.badges[0]);
Object.assign(badge.properties, {
value: ' text ',
type: 'text',
displayType: Badge.TYPES.PATTERN,
});
return (
<BadgeFacetedProvider value={{}}>
<BadgesGenerator
badges={[badge]}
badgesDictionary={badgesDictionary}
getBadgeFromDict={getBadgesFromDict}
t={t}
/>
</BadgeFacetedProvider>
);
};

export const DatePicker = () => {
const { t } = useTranslation();
const badgesDictionary = createBadgesDict();
const badge = cloneDeep(badgesFaceted.badges[0]);
Object.assign(badge.properties, {
value: Date.now(),
type: 'date',
});
return (
<BadgeFacetedProvider value={{}}>
<BadgesGenerator
badges={[badge]}
badgesDictionary={badgesDictionary}
getBadgeFromDict={getBadgesFromDict}
t={t}
/>
</BadgeFacetedProvider>
);
};

export const ReadOnly = () => {
const { t } = useTranslation();
const badgesDictionary = createBadgesDict();
return (
<BadgeFacetedProvider value={{}}>
<BadgesGenerator
badges={[
set(cloneDeep(badgesFaceted.badges[0]), 'properties.readOnly', true),
set(cloneDeep(badgesFaceted.badges[0]), 'properties.removable', false),
]}
badgesDictionary={badgesDictionary}
getBadgeFromDict={getBadgesFromDict}
t={t}
/>
</BadgeFacetedProvider>
);
};
2 changes: 1 addition & 1 deletion packages/faceted-search/stories/facetedSearch.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const badgesWithAll = {
};

export default {
title: 'Faceted search',
title: 'Faceted search/Main',
component: FacetedSearch.Faceted,
parameters: {
docs: {
Expand Down
28 changes: 0 additions & 28 deletions packages/icons/stories/DeprecatedIcon.stories.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions packages/icons/stories/DeprecatedIcons.stories.mdx

This file was deleted.

43 changes: 43 additions & 0 deletions packages/icons/stories/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Icon from './Icon';
import { info as icons } from '../dist/info';

export default {
title: 'Icons/Icon',
component: Icon,
};

export const Usage = {
args: {
name: 'talend-box',
},
argTypes: {
name: {
options: Object.keys(icons),
control: {
type: 'select',
},
},
},
};

export const All = props => {
const names = Object.keys(icons);
return (
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
{names.map(name => (
<div
key={name}
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
margin: '1rem',
}}
>
<Icon name={name} />
<span style={{ fontSize: '2rem' }}>{name}</span>
</div>
))}
</div>
);
};
5 changes: 4 additions & 1 deletion packages/storybook-one/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ const STORIES = [
`${rootPath}../forms/**/*.stories.@(js|tsx)`,
`${rootPath}../dataviz/src/**/*.stories.@(js|tsx)`,
`${rootPath}../icons/stories/**/*.stories.@(js|tsx)`,
`${rootPath}../faceted-search/stories/**/*.stories.@(js|tsx)`,
];

const monoRepoFixSourceMap = [
'../design-system/src',
'../components/src',
'../dataviz/src',
'../design-system/src',
'../faceted-search/stories',
'../faceted-search/src',
'../forms/src',
'../forms/stories',
'../icons/stories',
Expand Down
7 changes: 6 additions & 1 deletion packages/storybook-one/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": "@talend/scripts-config-typescript/tsconfig.json",
"include": ["src/**/*", "../components/src/**/*", "../forms/src/**/*"],
"include": [
"src/**/*",
"../components/src/**/*",
"../forms/src/**/*",
"../faceted-search/src/**/*"
],
"compilerOptions": {
"baseUrl": ".",
"module": "CommonJs",
Expand Down
File renamed without changes.

0 comments on commit 9141ffa

Please sign in to comment.