Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,16 @@ export const InternalShadowRoundButton = <C extends ElementType = "button">(
...rest
} = props;

const iconColorFilter = disabled
? disabledIconColor
: defaultIconColor ?? null;

const icon = iconName && (
<OakIcon
iconName={iconName}
$width={iconSize}
$height={iconSize}
$colorFilter={
props.disabled
? disabledIconColor
: defaultIconColor
? defaultIconColor
: null
}
$colorFilter={iconColorFilter}
data-icon-for="button"
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe(OakModalCenter, () => {
it("hides close button when hideCloseButton is true", () => {
const onCloseSpy = jest.fn();

const { queryAllByTestId } = renderWithTheme(
const { queryByTestId } = renderWithTheme(
<OakModalCenter isOpen onClose={onCloseSpy} hideCloseButton={true}>
Modal content
</OakModalCenter>,
);

expect(queryAllByTestId("close-button")).toBeNull;
expect(queryByTestId("close-button")).toBeNull();
});

it("calls onClose when the backdrop is clicked", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("OakCodeRenderer", () => {
const { getByText } = renderWithTheme(
<OakCodeRenderer string={mockString} />,
);
expect(getByText("output")).toBeInTheDocument;
expect(getByText("output")).toBeInTheDocument();
});

it("matches snapshot", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ export const OakLessonNavItem = <C extends ElementType = "a">(
disabledBackgroundColor,
] = pickColorsForSection(lessonSectionName);

const resolvedBackgroundColor =
isDisabled && disabledBackgroundColor
? disabledBackgroundColor
: progress === "not-started"
? notStartedBackgroundColor
: backgroundColor;
let resolvedBackgroundColor;
if (isDisabled && disabledBackgroundColor) {
resolvedBackgroundColor = disabledBackgroundColor;
} else if (progress === "not-started") {
resolvedBackgroundColor = notStartedBackgroundColor;
} else {
resolvedBackgroundColor = backgroundColor;
}

return (
<StyledLessonNavItem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from "react";
import React, { ReactNode, useMemo } from "react";
import styled from "styled-components";

import {
Expand Down Expand Up @@ -145,6 +145,22 @@ const Accordion = ({
);
};

const ControlledAccordion = (
props: UnstyledChevronAccordionCommonProps &
UnstyledChevronAccordionControlledProps,
) => {
const { isOpen, onOpenChange, ...accordionProps } = props;
const contextValue = useMemo(
() => ({ isOpen, setOpen: onOpenChange }),
[isOpen, onOpenChange],
);
return (
<accordionContext.Provider value={contextValue}>
<Accordion {...accordionProps} />
</accordionContext.Provider>
);
};

/**
* - UnstyledChevronAccordion has a chevron icon that rotates when the accordion is open.
* - Unlike InternalChevronAccordion, it has no border effects for hover or focus states.
Expand All @@ -158,12 +174,7 @@ export const UnstyledChevronAccordion = (
) => {
// Is the accordion being used as a controlled component?
if (props.isOpen !== undefined) {
const { isOpen, onOpenChange, ...accordionProps } = props;
return (
<accordionContext.Provider value={{ isOpen, setOpen: onOpenChange }}>
<Accordion {...accordionProps} />
</accordionContext.Provider>
);
return <ControlledAccordion {...props} />;
}

const { isInitiallyOpen = false, ...accordionProps } = props;
Expand Down