Skip to content

Commit

Permalink
Merge pull request #169 from likhith-deriv/likhith/feq-2136/accordion…
Browse files Browse the repository at this point in the history
…-title-enhancement

likhith/feq-2136/chore: added icon support for Accordion title
  • Loading branch information
shayan-deriv authored Apr 25, 2024
2 parents 292b23a + 7877f8f commit d509344
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type AccordionProps = {
children: ReactNode;
defaultOpen?: boolean;
isCompact?: boolean;
title: string;
title: string | JSX.Element;
variant?: AccordionVariants;
};

Expand Down Expand Up @@ -51,7 +51,7 @@ export const Accordion = ({
onClick={toggleAccordion}
aria-expanded={active}
>
<p>{title}</p>
{typeof title === "string" ? <p>{title}</p> : title}
<img
src={Chevron}
className={clsx("deriv-accordion__icon", {
Expand Down
22 changes: 21 additions & 1 deletion stories/Accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Accordion } from "../src/main";
import DerivBrandLogo from "./mock/brand-deriv-logo.svg";

const meta = {
title: "Components/Accordion",
Expand All @@ -17,7 +18,6 @@ const meta = {
variant: "underline",
},
argTypes: {
title: { control: { type: "text" } },
defaultOpen: { control: { type: "boolean" } },
variant: {
options: ["underline", "bordered", "shadow"],
Expand Down Expand Up @@ -67,6 +67,26 @@ export const Bordered: Story = {
),
};

export const BorderedWithIcons: Story = {
args: {
variant: "bordered",
title: (
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
<img src={DerivBrandLogo} height={40} width={40} />
<span>What is your return policy?</span>
</div>
),
},
render: (args) => (
<div {...props}>
<Accordion {...args}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</Accordion>
</div>
),
};

export const Shadow: Story = {
args: {
variant: "shadow",
Expand Down
1 change: 1 addition & 0 deletions stories/mock/brand-deriv-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d509344

Please sign in to comment.