Skip to content

Commit

Permalink
Merge branch 'master' into button-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Oct 12, 2020
2 parents ec74c9f + c522af5 commit 5bacdf4
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 289 deletions.
27 changes: 27 additions & 0 deletions packages/components/docs/sass.md
Original file line number Diff line number Diff line change
Expand Up @@ -8208,6 +8208,7 @@ $disabled-01: if(
- **Type**: `{undefined}`
- **Used by**:
- [carbon--theme [mixin]](#carbon--theme-mixin)
- [accordion [mixin]](#accordion-mixin)
- [content-switcher [mixin]](#content-switcher-mixin)
- [file-uploader [mixin]](#file-uploader-mixin)
- [slider [mixin]](#slider-mixin)
Expand Down Expand Up @@ -8241,6 +8242,7 @@ $disabled-02: if(
- **Type**: `{undefined}`
- **Used by**:
- [carbon--theme [mixin]](#carbon--theme-mixin)
- [accordion [mixin]](#accordion-mixin)
- [button [mixin]](#button-mixin)
- [button-base [mixin]](#button-base-mixin)
- [button-theme [mixin]](#button-theme-mixin)
Expand Down Expand Up @@ -13638,6 +13640,29 @@ Accordion styles
}
}

// Disabled styles
.#{$prefix}--accordion__heading[disabled] {
color: $disabled-02;
cursor: not-allowed;
}

.#{$prefix}--accordion__heading[disabled] .#{$prefix}--accordion__arrow {
fill: $disabled-02;
}

.#{$prefix}--accordion__heading[disabled]:hover::before {
background-color: transparent;
}

.#{$prefix}--accordion__item--disabled,
.#{$prefix}--accordion__item--disabled ~ * {
border-top: 1px solid $disabled-01;
}

li.#{$prefix}--accordion__item--disabled:last-of-type {
border-bottom: 1px solid $disabled-01;
}

.#{$prefix}--accordion__arrow {
@include focus-outline('reset');
// Without flex basis and flex shrink being set here, our icon width can go
Expand Down Expand Up @@ -13795,6 +13820,8 @@ Accordion styles
- [ui-03 [variable]](#ui-03-variable)
- [text-01 [variable]](#text-01-variable)
- [hover-ui [variable]](#hover-ui-variable)
- [disabled-02 [variable]](#disabled-02-variable)
- [disabled-01 [variable]](#disabled-01-variable)
- [ui-05 [variable]](#ui-05-variable)
- [carbon--spacing-05 [variable]](#carbon--spacing-05-variable)
- [carbon--spacing-09 [variable]](#carbon--spacing-09-variable)
Expand Down
23 changes: 23 additions & 0 deletions packages/components/src/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@
}
}

// Disabled styles
.#{$prefix}--accordion__heading[disabled] {
color: $disabled-02;
cursor: not-allowed;
}

.#{$prefix}--accordion__heading[disabled] .#{$prefix}--accordion__arrow {
fill: $disabled-02;
}

.#{$prefix}--accordion__heading[disabled]:hover::before {
background-color: transparent;
}

.#{$prefix}--accordion__item--disabled,
.#{$prefix}--accordion__item--disabled ~ * {
border-top: 1px solid $disabled-01;
}

li.#{$prefix}--accordion__item--disabled:last-of-type {
border-bottom: 1px solid $disabled-01;
}

.#{$prefix}--accordion__arrow {
@include focus-outline('reset');
// Without flex basis and flex shrink being set here, our icon width can go
Expand Down
6 changes: 6 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Map {
"className": Object {
"type": "string",
},
"disabled": Object {
"type": "bool",
},
},
},
"AccordionItem" => Object {
Expand All @@ -32,6 +35,9 @@ Map {
"className": Object {
"type": "string",
},
"disabled": Object {
"type": "bool",
},
"iconDescription": [Function],
"onClick": Object {
"type": "func",
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/components/Accordion/Accordion-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const props = {

export const playground = () => (
<Accordion
disabled={boolean('Disable entire Accordion (disabled)', false)}
align={select(
'Accordion heading alignment (align)',
['start', 'end'],
Expand All @@ -113,7 +114,10 @@ export const playground = () => (
commodo consequat.
</p>
</AccordionItem>
<AccordionItem title="Section 3 title" {...props}>
<AccordionItem
title="Section 3 title"
{...props}
disabled={boolean('Disable Section 3 (disabled)', true)}>
<Button>This is a button.</Button>
</AccordionItem>
<AccordionItem
Expand Down
19 changes: 17 additions & 2 deletions packages/react/src/components/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ import React from 'react';

const { prefix } = settings;

function Accordion({ align, children, className: customClassName, ...rest }) {
function Accordion({
align,
children,
className: customClassName,
disabled,
...rest
}) {
const className = cx(`${prefix}--accordion`, customClassName, {
[`${prefix}--accordion--${align}`]: align,
});
return (
<ul className={className} {...rest}>
{children}
{disabled
? React.Children.toArray(children).map((child) => {
return React.cloneElement(child, { disabled });
})
: children}
</ul>
);
}
Expand All @@ -42,6 +52,11 @@ Accordion.propTypes = {
* Specify an optional className to be applied to the container node
*/
className: PropTypes.string,

/**
* Specify whether an individual AccordionItem should be disabled
*/
disabled: PropTypes.bool,
};

export default Accordion;
8 changes: 8 additions & 0 deletions packages/react/src/components/Accordion/AccordionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function AccordionItem({
onHeadingClick,
renderExpando: Expando = defaultRenderExpando,
title = 'title',
disabled,
...rest
}) {
const [isOpen, setIsOpen] = useState(open);
Expand All @@ -35,6 +36,7 @@ function AccordionItem({
[`${prefix}--accordion__item`]: true,
[`${prefix}--accordion__item--active`]: isOpen,
[`${prefix}--accordion__item--${animation}`]: animation,
[`${prefix}--accordion__item--disabled`]: disabled,
[customClassName]: !!customClassName,
});

Expand Down Expand Up @@ -73,6 +75,7 @@ function AccordionItem({
return (
<li className={className} {...rest} onAnimationEnd={handleAnimationEnd}>
<Expando
disabled={disabled}
aria-controls={id}
aria-expanded={isOpen}
className={`${prefix}--accordion__heading`}
Expand Down Expand Up @@ -100,6 +103,11 @@ AccordionItem.propTypes = {
*/
className: PropTypes.string,

/**
* Specify whether an individual AccordionItem should be disabled
*/
disabled: PropTypes.bool,

/**
* The description of the expando icon.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ export const UsingHeaderFooterProps = () => {
{...bodyProps}
aria-label={hasScrollingContent ? 'Modal content' : undefined}>
<p className={`${prefix}--modal-content__text`}>
Please see ModalWrapper for more examples and demo of the
functionality.
Please see the &quot;With Trigger Button&quot; storybook example for a
demo of this functionality.
</p>
<br />
{hasScrollingContent && scrollingContent}
</ModalBody>
<ModalFooter {...props.modalFooter()} />
Expand Down Expand Up @@ -234,9 +235,10 @@ export const UsingChildNodes = () => {
{...bodyProps}
aria-label={hasScrollingContent ? 'Modal content' : undefined}>
<p>
Please see ModalWrapper for more examples and demo of the
functionality.
Please see the &quot;With Trigger Button&quot; storybook example for a
demo of this functionality.
</p>
<br />
{hasScrollingContent && scrollingContent}
</ModalBody>
<ModalFooter>
Expand Down Expand Up @@ -299,10 +301,6 @@ export const WithTriggerButton = () => {
<ModalBody
{...bodyProps}
aria-label={hasScrollingContent ? 'Modal content' : undefined}>
<p className={`${prefix}--modal-content__text`}>
Please see ModalWrapper for more examples and demo of the
functionality.
</p>
{hasScrollingContent && scrollingContent}
</ModalBody>
<ModalFooter {...props.modalFooter()} />
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/components/ComposedModal/ComposedModal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ const ModalStateManager = ({
};
```

`<ModalWrapper>` is a modal state manager implementation which ships out of the
box with Carbon.

<InlineNotification
kind="warning"
title="Warning"
Expand Down
8 changes: 3 additions & 5 deletions packages/react/src/components/Modal/Modal-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ export const Default = () => {
return (
<Modal {...rest} size={size || undefined}>
<p className={`${prefix}--modal-content__text`}>
Please see ModalWrapper for more examples and demo of the functionality.
Please see the &quot;With State Manager&quot; storybook example for a
demo of this functionality.
</p>
<br />
{rest.hasScrollingContent && (
<>
<p>
Expand Down Expand Up @@ -265,10 +267,6 @@ export const WithStateManager = () => {
size={size || undefined}
open={open}
onRequestClose={() => setOpen(false)}>
<p className={`${prefix}--modal-content__text`}>
Please see ModalWrapper for more examples and demo of the
functionality.
</p>
{rest.hasScrollingContent && (
<>
<p>
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/components/Modal/Modal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ const ModalStateManager = ({
};
```

`<ModalWrapper>` is a modal state manager implementation which ships out of the
box with Carbon.

<InlineNotification title="Warning" kind="warning">
<code>{`<Modal>`}</code>/<code>{`<ComposedModal>`}</code> has to be put at the
top level in a React tree. The easiest way to ensure that is using React
Expand Down
Loading

0 comments on commit 5bacdf4

Please sign in to comment.