Skip to content

Commit

Permalink
Merge branch 'carbon-design-system:main' into fix/es-build-size
Browse files Browse the repository at this point in the history
  • Loading branch information
salvoravida authored Oct 25, 2021
2 parents a50227c + 39091b0 commit 3fb3ae1
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 11 deletions.
2 changes: 2 additions & 0 deletions packages/carbon-react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module.exports = {
'./Welcome/Welcome.stories.js',
'../src/**/*.stories.js',
'../src/**/*.stories.mdx',
'../../react/src/**/next/*.stories.js',
'../../react/src/**/next/*.stories.mdx',
],
webpack(config) {
const babelLoader = config.module.rules.find((rule) => {
Expand Down
17 changes: 12 additions & 5 deletions packages/react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

'use strict';

const glob = require('fast-glob');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const customProperties = require('postcss-custom-properties');
Expand Down Expand Up @@ -36,11 +37,17 @@ module.exports = {
require.resolve('./addon-theme/register'),
],

stories: [
'./Welcome/Welcome.stories.js',
'../src/**/*-story.js',
'../src/**/*.stories.mdx',
],
stories: glob.sync(
[
'./Welcome/Welcome.stories.js',
'../src/**/*-story.js',
'../src/**/*.stories.mdx',
],
{
cwd: __dirname,
ignore: ['../**/next/**'],
}
),

webpack(config) {
const babelLoader = config.module.rules.find((rule) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5692,6 +5692,9 @@ Map {
},
"displayName": "Switch",
"propTypes": Object {
"children": Object {
"type": "node",
},
"className": Object {
"type": "string",
},
Expand Down Expand Up @@ -5724,7 +5727,6 @@ Map {
"type": "bool",
},
"text": Object {
"isRequired": true,
"type": "string",
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"css-loader": "^3.4.2",
"cypress": "^8.1.0",
"cypress-real-events": "^1.5.1",
"fast-glob": "^3.2.7",
"fast-sass-loader": "^1.5.0",
"gzip-size": "^6.0.0",
"lcov2badge": "^0.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
} from '@carbon/icons-react';
import { withKnobs, boolean, select } from '@storybook/addon-knobs';
import React from 'react';
import { Popover, PopoverContent } from '../Popover';
import Button from '../Button';
import { Popover, PopoverContent } from '../../Popover';
import Button from '../../Button';
import mdx from './Popover.mdx';
import { useOutsideClick } from '../../internal/useOutsideClick';
import { useOutsideClick } from '../../../internal/useOutsideClick';

export default {
title: 'Experimental/unstable_Popover',
Expand Down
10 changes: 8 additions & 2 deletions packages/react/src/components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { prefix } = settings;

const Switch = React.forwardRef(function Switch(props, tabRef) {
const {
children,
className,
disabled,
index,
Expand Down Expand Up @@ -57,7 +58,7 @@ const Switch = React.forwardRef(function Switch(props, tabRef) {
{...other}
{...commonProps}>
<span className={`${prefix}--content-switcher__label`} title={text}>
{text}
{text !== undefined ? text : children}
</span>
</button>
);
Expand All @@ -66,6 +67,11 @@ const Switch = React.forwardRef(function Switch(props, tabRef) {
Switch.displayName = 'Switch';

Switch.propTypes = {
/**
* Provide child elements to be rendered inside of the Switch
*/
children: PropTypes.node,

/**
* Specify an optional className to be added to your Switch
*/
Expand Down Expand Up @@ -107,7 +113,7 @@ Switch.propTypes = {
/**
* Provide the contents of your Switch
*/
text: PropTypes.string.isRequired,
text: PropTypes.string,
};

Switch.defaultProps = {
Expand Down
46 changes: 46 additions & 0 deletions packages/react/src/components/Text/Text-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { LayoutDirection } from '../Layout';
import { TextDirection, Text } from '../Text';
import RadioButtonGroup from '../RadioButtonGroup';
import RadioButton from '../RadioButton';
import Button from '../Button';
import Dropdown from '../Dropdown';
import ContentSwitcher from '../ContentSwitcher';
import Switch from '../Switch';
import { Heading } from '../Heading';

export default {
title: 'Experimental/unstable_Text',
Expand Down Expand Up @@ -88,3 +93,44 @@ export const SetTextDirection = () => {
</TextDirection>
);
};

export const ComponentExamples = () => {
const rtlText = 'שלום!!';
const dropdownItems = [
{
id: 'option-0',
text: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit.',
},
{
id: 'option-1',
text: rtlText,
},
];
return (
<>
<Heading>{rtlText}</Heading>
<Button kind="ghost">
<Text>{rtlText}</Text>
</Button>
<div style={{ width: 400 }}>
<Dropdown
id="default"
titleText="Using <Text> with `itemToElement`"
helperText="This is some helper text"
label="Dropdown menu options"
items={dropdownItems}
itemToElement={(item) => <Text>{item.text}</Text>}
/>
</div>
<ContentSwitcher
helperText="Using <Text> within <Switch>"
onChange={() => {}}>
<Switch name="one">
<Text>{rtlText}</Text>
</Switch>
<Switch name="two" text="Second section" />
<Switch name="three" text="Third section" />
</ContentSwitcher>
</>
);
};
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10349,6 +10349,7 @@ __metadata:
cypress: ^8.1.0
cypress-real-events: ^1.5.1
downshift: 5.2.1
fast-glob: ^3.2.7
fast-sass-loader: ^1.5.0
flatpickr: 4.6.9
gzip-size: ^6.0.0
Expand Down

0 comments on commit 3fb3ae1

Please sign in to comment.