Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(icon-switch): design updates #2819

Merged
merged 16 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import merge from 'lodash/merge';
import { action } from '@storybook/addon-actions';
import { withKnobs } from '@storybook/addon-knobs';
import { boolean, withKnobs } from '@storybook/addon-knobs';
import {
purple70,
cyan50,
Expand Down Expand Up @@ -50,6 +50,7 @@ const colors = [
];

export const Default = () => {
const isLight = boolean('light', true);
const WithState = () => {
const [formValues, setFormValues] = useState({});

Expand All @@ -73,6 +74,7 @@ export const Default = () => {
action('onDelete')(change);
}}
translateWithId={() => {}}
light={isLight}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-bold"
disabled={false}
onBlur={[Function]}
Expand All @@ -42,6 +42,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Bold
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Bold"
Expand All @@ -63,7 +66,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-italic"
disabled={false}
onBlur={[Function]}
Expand All @@ -81,6 +84,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Italic
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Italic"
Expand All @@ -102,7 +108,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-underline"
disabled={false}
onBlur={[Function]}
Expand All @@ -120,6 +126,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Underline
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Underline"
Expand Down Expand Up @@ -698,7 +707,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-bold"
disabled={false}
onBlur={[Function]}
Expand All @@ -716,6 +725,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Bold
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Bold"
Expand All @@ -737,7 +749,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-italic"
disabled={false}
onBlur={[Function]}
Expand All @@ -755,6 +767,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Italic
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Italic"
Expand All @@ -776,7 +791,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
<button
aria-describedby={null}
aria-pressed={null}
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
className="iot--icon-switch iot--icon-switch--default iot--icon-switch--light iot--icon-switch--unselected iot--icon-switch--unselected--light bx--btn bx--btn--secondary bx--tooltip--hidden bx--btn--icon-only bx--tooltip__trigger bx--tooltip--a11y bx--btn--icon-only--top bx--tooltip--align-center"
data-testid="hotspot-underline"
disabled={false}
onBlur={[Function]}
Expand All @@ -794,6 +809,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots 2 - Watson IoT E
>
Text Underline
</div>
<span
className="iot--icon-switch__divider"
/>
<svg
aria-hidden="true"
aria-label="Text Underline"
Expand Down
15 changes: 14 additions & 1 deletion packages/react/src/components/IconSwitch/IconSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const IconSwitch = React.forwardRef((props, ref) => {
text,
light,
testId,
children,
...other
} = props;

Expand All @@ -53,6 +54,8 @@ const IconSwitch = React.forwardRef((props, ref) => {
className,
`${iotPrefix}--icon-switch`,
`${iotPrefix}--icon-switch--${size}`,
{ [`${iotPrefix}--icon-switch--selected`]: selected },
{ [`${iotPrefix}--icon-switch--light`]: light },
{ [`${iotPrefix}--icon-switch--unselected`]: !selected },
{ [`${iotPrefix}--icon-switch--unselected--light`]: light && !selected }
);
Expand All @@ -74,7 +77,10 @@ const IconSwitch = React.forwardRef((props, ref) => {
data-testid={testId}
{...other}
{...commonProps}
/>
>
{children}
<span className={`${iotPrefix}--icon-switch__divider`} />
</CarbonButton>
);
});

Expand Down Expand Up @@ -143,6 +149,11 @@ IconSwitch.propTypes = {
light: PropTypes.bool,

testId: PropTypes.string,

/** The button should be disabled */
disabled: PropTypes.bool,

children: PropTypes.node,
};

IconSwitch.defaultProps = {
Expand All @@ -154,6 +165,8 @@ IconSwitch.defaultProps = {
onClick: undefined,
onKeyDown: undefined,
testId: 'icon-switch',
disabled: false,
children: undefined,
};

export default IconSwitch;
Loading