Skip to content

Commit

Permalink
Merge pull request #43 from linked-planet/dev
Browse files Browse the repository at this point in the history
added options  for data-props to accordion, collapsible and button group
  • Loading branch information
marcus-wishes authored Sep 18, 2024
2 parents 1f0f4c8 + dcc549a commit 9a10e0b
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 244 deletions.
12 changes: 8 additions & 4 deletions library/src/components/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ type AccordionMultipleProps = Pick<
type AccordionContainerProps = (
| AccordionSingleProps
| AccordionMultipleProps
) & { testId?: string }
) & {
"data-testid"?: string
"data-id"?: string
}

const Container = ({ testId, ...props }: AccordionContainerProps) => {
return <RAccordion.Root data-testid={testId} {...props} />
const Container = (props: AccordionContainerProps) => {
return <RAccordion.Root {...props} />
}

type AccordionItemProps = Pick<
Expand All @@ -51,11 +54,12 @@ const AccordionItem = React.forwardRef(
forwardedRef: Ref<HTMLDivElement>,
) => (
<RAccordion.Item
{...props}
className={twMerge(
"border-border overflow-hidden border-b-2 first:rounded-t last:rounded-b last:border-b-0 focus-within:relative focus-within:z-10",
className,
)}
{...props}

ref={forwardedRef}
>
{children}
Expand Down
11 changes: 5 additions & 6 deletions library/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type React from "react"
import { type CSSProperties, forwardRef, useMemo } from "react"
import { type CSSProperties, forwardRef, type HTMLProps, useMemo } from "react"
import { twJoin, twMerge } from "tailwind-merge"
import { LoadingSpinner } from "./LoadingSpinner"

Expand Down Expand Up @@ -211,15 +211,14 @@ export const ButtonGroup = ({
children,
className,
style,
}: {
children: React.ReactNode
className?: string
style?: CSSProperties
}) => {
...props
}: HTMLProps<HTMLDivElement>) => {
return (
<div
{...props}
className={twMerge("inline-flex flex-wrap gap-2 p-2", className)} //gap-2 and p-2 are because of the button outlines on focus
style={style}

>
{children}
</div>
Expand Down
7 changes: 5 additions & 2 deletions library/src/components/Collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ChevronDownIcon from "@atlaskit/icon/glyph/chevron-down"
import ChevronRightIcon from "@atlaskit/icon/glyph/chevron-right"
import ChevronUpIcon from "@atlaskit/icon/glyph/chevron-up"
import * as CollapsibleRUI from "@radix-ui/react-collapsible"
import { forwardRef, useCallback, useState } from "react"
import { forwardRef, type HTMLProps, useCallback, useState } from "react"
import { twMerge } from "tailwind-merge"

type CollapsibleProps = {
Expand All @@ -22,7 +22,7 @@ type CollapsibleProps = {
openButtonPosition?: "left" | "right" | "hidden"
id?: string
testId?: string
}
} & HTMLProps<HTMLDivElement>

export const Collapsible = forwardRef(
(
Expand All @@ -43,6 +43,7 @@ export const Collapsible = forwardRef(
children,
id,
testId,
...props
}: CollapsibleProps,
ref: React.ForwardedRef<HTMLDivElement>,
) => {
Expand Down Expand Up @@ -76,6 +77,7 @@ export const Collapsible = forwardRef(

return (
<CollapsibleRUI.Root
{...props}
open={open}
defaultOpen={defaultOpen}
onOpenChange={openCB}
Expand All @@ -84,6 +86,7 @@ export const Collapsible = forwardRef(
data-testid={testId}
id={id}
ref={ref}

>
<CollapsibleRUI.Trigger
className={twMerge(
Expand Down
2 changes: 1 addition & 1 deletion library/src/layouting/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Container({
return (
<div
className={twMerge(
"relative m-0 box-border grid h-full min-h-dvh w-full",
"relative m-0 box-border grid h-dvh w-full",
className,
)}
data-layout-container="true"
Expand Down
Loading

0 comments on commit 9a10e0b

Please sign in to comment.