Skip to content

Commit

Permalink
Pre-formatted text Design System
Browse files Browse the repository at this point in the history
  • Loading branch information
JadhavJeet committed Nov 16, 2023
1 parent d25ed22 commit 68a64cf
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/design-system/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
@import './insert-text.css';
@import './heading.css';
@import './highlight.css';
@import './keyboard-input.css';
@import './keyboard-input.css';
@import './preformattedText.css';
7 changes: 7 additions & 0 deletions src/design-system/preformattedText.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dcx-pre {
color: token('color-text-pre_body');
background-color: token('color-background-pre_box');
font-size: token('font-size-pre_body');
font-family: token('font-family-pre_body');
font-weight: token('font-weight-pre_body');
}
5 changes: 3 additions & 2 deletions src/design-system/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"color-background-formcontrol_label": "transparent",
"color-background-formcontrol_label-floating": "white",
"color-background-highlight_body": "yellow",
"color-background-pre_box": "white",
"color-chevron-formcontrol": "#000",
"color-chevron-formcontrol-filled": "#000",
"color-chevron-formcontrol-floating": "#000",
Expand Down Expand Up @@ -85,7 +86,7 @@
"color-text-heading-level_6": "#000",
"color-text-highlight_body": "black",
"color-text-paragraph": "black",
"color-text-pre_body": "#000",
"color-text-pre_body": "#000",
"font-action-line-height": "20px",
"font-action-size": "16px",
"font-action_label-line-height": "20px",
Expand Down Expand Up @@ -128,4 +129,4 @@
"spacing-y-action": "10px",
"spacing-y-formcontrol": "15px",
"spacing-y-formcontrol-floating": "30px"
}
}
53 changes: 53 additions & 0 deletions stories/PreformattedText/design-system/AccessibleTheme.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { PreformattedText } from '../../../src/preformattedText/PreformattedText';
import style from '!raw-loader!../../themes/accessible.theme.css';
import { LiveProvider, LiveEditor } from 'react-live';
import { StorybookUtils } from '../../../core/storybook/StorybookUtils';

/**
* This a theme aimed at easing the vizualization of the different elements of the component in order to improve the experience for people that have visual impairments.
*/
export default {
title: 'DCXLibrary/Typography/PreformattedText/Design system/Accessible',
component: PreformattedText,
decorators: [
getStory => {
require('../../../dist/design-system/index.css');
require('../../themes/accessible.theme.css');
return getStory();
},
],
parameters: {
options: { showPanel: true },
actions: { disable: true },
},
tags: ['autodocs'],
};

export const ShowCase = {
parameters: {
backgrounds: {
default: 'dark',
values: [
{ name: 'dark', value: '#282c34' },
{ name: 'light', value: '#fff' },
],
},
},
render: () => (
<LiveProvider
code={StorybookUtils.getThemeCode('dcx-pre', style)}
disabled={true}
language="css"
>
<LiveEditor className="liveEditor" aria-label="editor" />
</LiveProvider>
),
};

export const Default = {
name: 'Default',
args: {
value: `Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and
line breaks.`,
},
};
63 changes: 63 additions & 0 deletions stories/PreformattedText/design-system/DarkTheme.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { PreformattedText } from '../../../src/preformattedText/PreformattedText';
// eslint-disable-next-line import/no-webpack-loader-syntax
import style from '!raw-loader!../../themes/dark.theme.css';
import { LiveProvider, LiveEditor } from 'react-live';
import { StorybookUtils } from '../../../core/storybook/StorybookUtils';

/**
* This a theme showcases how to customize the component so it can be used on dark backgrounds.
*/
export default {
title: 'DCXLibrary/Typography/PreformattedText/Design system/Dark',
component: PreformattedText,
decorators: [
getStory => {
require('../../../dist/design-system/index.css');
require('../../themes/dark.theme.css');
return getStory();
},
],
parameters: {
options: { showPanel: true },
actions: { disable: true },
},
tags: ['autodocs'],
};

export const ShowCase = {
parameters: {
backgrounds: {
default: 'dark',
values: [
{ name: 'dark', value: '#282c34' },
{ name: 'light', value: '#fff' },
],
},
},
render: () => (
<LiveProvider
code={StorybookUtils.getThemeCode('dcx-pre', style)}
disabled={true}
language="css"
>
<LiveEditor className="liveEditor" aria-label="editor" />
</LiveProvider>
),
};

export const Default = {
name: 'Default',
parameters: {
backgrounds: {
default: 'dark',
values: [
{ name: 'dark', value: '#282c34' },
{ name: 'light', value: '#fff' },
],
},
},
args: {
value: `Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and
line breaks.`,
},
};
27 changes: 27 additions & 0 deletions stories/PreformattedText/design-system/Default.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { PreformattedText } from '../../../src/preformattedText/PreformattedText';
/**
* Here we display the component in its natural preformattedText, importing only the base Design System styles.
*/
export default {
title: 'DCXLibrary/Typography/PreformattedText/Design system/Default',
component: PreformattedText,
decorators: [
getStory => {
require('../../../dist/design-system/index.css');
return getStory();
},
],
parameters: {
options: { showPanel: true },
actions: { disable: true },
},
tags: ['autodocs'],
};

export const Default = {
name: 'Default',
args: {
value: `Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and
line breaks.`,
},
};
55 changes: 55 additions & 0 deletions stories/PreformattedText/design-system/MaterialTheme.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { PreformattedText } from '../../../src/preformattedText/PreformattedText';
import { LiveProvider, LiveEditor } from 'react-live';
// eslint-disable-next-line import/no-webpack-loader-syntax
import style from '!raw-loader!../../themes/material.theme.css';
import { StorybookUtils } from '../../../core/storybook/StorybookUtils';

/**
* This a theme showcases an appearance similar to Material UI can be achieved.
* If you copy paste this snippet inside your css file you'll get a material design style
*/
export default {
title: 'DCXLibrary/Typography/PreformattedText/Design system/Material',
component: PreformattedText,
decorators: [
getStory => {
require('../../../dist/design-system/index.css');
require('../../themes/material.theme.css');
return getStory();
},
],
parameters: {
options: { showPanel: true },
actions: { disable: true },
},
tags: ['autodocs'],
};

export const ShowCase = {
parameters: {
backgrounds: {
default: 'dark',
values: [
{ name: 'dark', value: '#282c34' },
{ name: 'light', value: '#fff' },
],
},
},
render: () => (
<LiveProvider
code={StorybookUtils.getThemeCode('dcx-pre', style)}
disabled={true}
language="css"
>
<LiveEditor className="liveEditor" aria-label="editor" />
</LiveProvider>
),
};

export const Default = {
name: 'Default',
args: {
value: `Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and
line breaks.`,
},
};
24 changes: 24 additions & 0 deletions stories/PreformattedText/design-system/Playground.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable import/no-webpack-loader-syntax */
import style from '!raw-loader!../../../dist/design-system/preformattedText.css';
import TokensDecorator from '../../../core/storybook/TokensDecorator';
import { PreformattedText } from '../../../src/preformattedText/PreformattedText';

export default {
title: 'DCXLibrary/Typography/PreformattedText/Design system',
component: PreformattedText,
decorators: [
getStory => <TokensDecorator style={style}>{getStory()}</TokensDecorator>,
],
parameters: {
options: { showPanel: true },
actions: { disable: true },
},
};

export const Playground = {
name: 'Playground',
args: {
value: `Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and
line breaks.`,
},
};
5 changes: 5 additions & 0 deletions stories/themes/accessible.theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
--dcx-color-text-body: #000;
--dcx-color-marker: #000;
}

.dcx-pre {
--dcx-font-size-pre_body: 18px;
--dcx-font-weight-pre_body: 500;
}
5 changes: 5 additions & 0 deletions stories/themes/dark.theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
--dcx-color-text-body: white;
}

.dcx-pre {
--dcx-color-text-pre_body: white;
--dcx-color-background-pre_box: transparent;
}

.dcx-insert-text {
--dcx-color-text-body: white;
}
Expand Down
5 changes: 5 additions & 0 deletions stories/themes/material.theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
--dcx-color-text-body: rgba(0, 0, 0, 0.6);
--dcx-color-marker: rgba(0, 0, 0, 0.6);
}

.dcx-pre {
--dcx-color-text-pre_body: rgba(0, 0, 0, 0.6);
}

0 comments on commit 68a64cf

Please # to comment.