Skip to content

Commit

Permalink
Fixed disabled accordions having status styling (#4013)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored Aug 22, 2024
1 parent 222c47a commit 77dc32e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-beers-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@salt-ds/core": patch
---

Fixed Accordion having status styling when disabled and status is set.
4 changes: 4 additions & 0 deletions packages/core/src/accordion/Accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
.saltAccordion-success {
border-top-color: var(--salt-status-success-borderColor);
}

.saltAccordion-disabled {
border-top-color: var(--salt-separable-tertiary-borderColor);
}
5 changes: 4 additions & 1 deletion packages/core/src/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
ref={ref}
className={clsx(
withBaseName(),
{ [withBaseName(status ?? "")]: status },
{
[withBaseName(status ?? "")]: status,
[withBaseName("disabled")]: disabled,
},
className,
)}
{...rest}
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/accordion/AccordionHeader.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
outline-offset: calc(-1 * var(--salt-focused-outlineWidth));
}

.saltAccordionHeader:disabled {
background: var(--salt-actionable-secondary-background);
color: var(--salt-content-primary-foreground-disabled);
cursor: var(--salt-actionable-cursor-disabled);
}

.saltAccordionHeader-content {
padding: var(--salt-spacing-75) 0;
width: 100%;
Expand Down Expand Up @@ -65,3 +59,9 @@
height: var(--salt-size-base);
margin-left: auto;
}

.saltAccordionHeader:disabled {
background: var(--salt-actionable-secondary-background);
color: var(--salt-content-primary-foreground-disabled);
cursor: var(--salt-actionable-cursor-disabled);
}
4 changes: 2 additions & 2 deletions packages/core/src/accordion/AccordionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const AccordionHeader = forwardRef<
if (id) {
setHeaderId(id);
}
}, [id]);
}, [id, setHeaderId]);

return (
<button
Expand All @@ -87,7 +87,7 @@ export const AccordionHeader = forwardRef<
>
{indicatorSide === "left" && <ExpansionIcon expanded={expanded} />}
<span className={withBaseName("content")}>{children}</span>
{status && (
{status && !disabled && (
<StatusIndicator
className={withBaseName("statusIndicator")}
status={status}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/accordion/AccordionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const AccordionPanel = forwardRef<HTMLDivElement, AccordionPanelProps>(
if (id) {
setPanelId(id);
}
}, [id]);
}, [id, setPanelId]);

return (
<div
Expand Down
42 changes: 9 additions & 33 deletions packages/core/stories/accordion/accordion.qa.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
const UI = () => (
<AccordionGroup>
<Accordion value="default">
<AccordionHeader>Accordion label</AccordionHeader>
<AccordionHeader>Default accordion</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
Expand All @@ -44,27 +44,11 @@ const UI = () => (
</AccordionPanel>
</Accordion>
<Accordion value="disabled" disabled>
<AccordionHeader>Accordion label</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
<FormField labelPlacement="left">
<FormLabel>Disclosure ID</FormLabel>
<Input />
</FormField>
<FormField labelPlacement="left">
<FormLabel>Email</FormLabel>
<Input />
</FormField>
<FormField labelPlacement="left">
<FormLabel>Justification</FormLabel>
<Input />
</FormField>
</FlowLayout>
</AccordionPanel>
<AccordionHeader>Disabled accordion</AccordionHeader>
<AccordionPanel />
</Accordion>
<Accordion value="error" status="error">
<AccordionHeader>Accordion label</AccordionHeader>
<AccordionHeader>Error accordion</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
Expand All @@ -84,7 +68,7 @@ const UI = () => (
</AccordionPanel>
</Accordion>
<Accordion value="warning" status="warning">
<AccordionHeader>Accordion label</AccordionHeader>
<AccordionHeader>Warning accordion</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
Expand All @@ -104,7 +88,7 @@ const UI = () => (
</AccordionPanel>
</Accordion>
<Accordion value="success" status="success">
<AccordionHeader>Accordion label</AccordionHeader>
<AccordionHeader>Success accordion</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
Expand All @@ -123,17 +107,9 @@ const UI = () => (
</FlowLayout>
</AccordionPanel>
</Accordion>
<Accordion value="default" indicatorSide="right">
<AccordionHeader>Right align indicator</AccordionHeader>
<AccordionPanel>
<FlowLayout>
This is content inside of an Accordion.
<FormField labelPlacement="left">
<FormLabel>Disclosure ID</FormLabel>
<Input />
</FormField>
</FlowLayout>
</AccordionPanel>
<Accordion value="success" status="success" disabled>
<AccordionHeader>Disabled success accordion</AccordionHeader>
<AccordionPanel />
</Accordion>
<Accordion value="default" expanded>
<AccordionHeader>Left align indicator</AccordionHeader>
Expand Down

0 comments on commit 77dc32e

Please sign in to comment.