Skip to content

Commit

Permalink
Merge branch 'main' into fix-input-length
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok authored Sep 29, 2023
2 parents 9dd2cbd + 1b5b017 commit 0a72be6
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 64 deletions.
39 changes: 38 additions & 1 deletion src/components/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
import { DropdownMenuProps } from "@radix-ui/react-dropdown-menu";
import { Dropdown } from "./Dropdown";
import { GridCenter } from "../commonElement";
import { Button } from "..";

interface Props extends DropdownMenuProps {
disabled?: boolean;
showArrow?: boolean;
side: "top" | "right" | "left" | "bottom";
type: "text" | "button";
}
const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
return (
<GridCenter>
<Dropdown {...props}>
<Dropdown.Trigger disabled={disabled}>Dropdown Trigger</Dropdown.Trigger>
<Dropdown.Content
showArrow={showArrow}
side={side}
>
<Dropdown.Group>
<Dropdown.Item>Content0</Dropdown.Item>
</Dropdown.Group>
<Dropdown.Item icon="activity">Content1 long text content</Dropdown.Item>
<Dropdown.Sub>
<Dropdown.Trigger sub>Hover over</Dropdown.Trigger>
<Dropdown.Content sub>
<Dropdown.Item>SubContent0</Dropdown.Item>
<Dropdown.Item>SubContent1</Dropdown.Item>
<Dropdown.Item>SubContent0</Dropdown.Item>
<Dropdown.Item>SubContent1</Dropdown.Item>
<Dropdown.Item>SubContent0</Dropdown.Item>
<Dropdown.Item>SubContent1</Dropdown.Item>
<Dropdown.Item>SubContent0</Dropdown.Item>
<Dropdown.Item>SubContent1</Dropdown.Item>
<Dropdown.Item>SubContent0</Dropdown.Item>
<Dropdown.Item>SubContent1</Dropdown.Item>
</Dropdown.Content>
</Dropdown.Sub>
<Dropdown.Item
icon="activity"
iconDir="end"
>
Content2
</Dropdown.Item>
<Dropdown.Item disabled>Content3</Dropdown.Item>
</Dropdown.Content>
</Dropdown>
<Dropdown {...props}>
<Dropdown.Trigger disabled={disabled}>
<div>Dropdown Trigger</div>
<Button>Dropdown Trigger Button</Button>
</Dropdown.Trigger>
<Dropdown.Content
showArrow={showArrow}
Expand Down Expand Up @@ -59,6 +95,7 @@ export default {
defaultOpen: { control: "boolean" },
showArrow: { control: "boolean" },
side: { control: "select", options: ["top", "right", "left", "bottom"] },
type: { control: "inline-radio", options: ["text", "button"] },
},
};

Expand Down
4 changes: 1 addition & 3 deletions src/components/Dropdown/Dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ describe("Dropdown", () => {
const renderDropdown = ({ disabled, ...props }: Props) =>
renderCUI(
<Dropdown {...props}>
<Dropdown.Trigger disabled={disabled}>
<div>Dropdown Trigger</div>
</Dropdown.Trigger>
<Dropdown.Trigger disabled={disabled}>Dropdown Trigger</Dropdown.Trigger>
<Dropdown.Content>
<Dropdown.Group>
<Dropdown.Item>Content0</Dropdown.Item>
Expand Down
11 changes: 9 additions & 2 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ type DropdownTriggerProps = DropdownMenu.DropdownMenuTriggerProps & MainDropdown
const Trigger = styled(DropdownMenu.Trigger)`
cursor: pointer;
width: fit-content;
&[disabled] {
cursor: not-allowed;
}
`;

const DropdownTrigger = ({
sub,
children,
...props
}: DropdownSubTriggerProps | DropdownTriggerProps) => {
if (sub) {
const { children, icon, iconDir, ...menuProps } = props as DropdownSubTriggerProps;
const { icon, iconDir, ...menuProps } = props as DropdownSubTriggerProps;
return (
<DropdownMenuItem
as={DropdownMenu.SubTrigger}
Expand All @@ -61,11 +65,14 @@ const DropdownTrigger = ({
</DropdownMenuItem>
);
}

return (
<Trigger
asChild
{...(props as DropdownTriggerProps)}
/>
>
<div>{children}</div>
</Trigger>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/Label/Label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
text: "Form Field label",
error: false,
Expand Down
24 changes: 21 additions & 3 deletions src/components/Popover/Popover.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Checkbox } from "..";
import { Button, Checkbox } from "..";
import { GridCenter } from "../commonElement";
import { Text } from "../Typography/Text/Text";
import { Title } from "../Typography/Title/Title";
Expand All @@ -20,12 +20,30 @@ const PopoverComponent = ({
side: "top" | "right" | "left" | "bottom";
}) => (
<GridCenter>
<Popover
open={open === "default" ? undefined : open === "open"}
modal={modal}
>
<Popover.Trigger>Click Here</Popover.Trigger>
<Popover.Content
side={side}
showArrow={showArrow}
showClose={showClose}
forceMount={forceMount ? true : undefined}
>
<Title type="h2">Content popover</Title>
<br />
<Text>Click on the input element below.</Text>
<br />
<Checkbox label="This is a sample data to experiment the popover" />
</Popover.Content>
</Popover>
<Popover
open={open === "default" ? undefined : open === "open"}
modal={modal}
>
<Popover.Trigger>
<div>Click Here</div>
<Button>Click Here Button</Button>
</Popover.Trigger>
<Popover.Content
side={side}
Expand Down Expand Up @@ -57,7 +75,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
open: "default",
showArrow: true,
Expand Down
4 changes: 1 addition & 3 deletions src/components/Popover/Popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ describe("Popover", () => {
const renderPopover = (props: PopoverProps) =>
renderCUI(
<Popover {...props}>
<Popover.Trigger>
<div>Click Here</div>
</Popover.Trigger>
<Popover.Trigger>Click Here</Popover.Trigger>
<Popover.Content>
<div>
Click on the input element below
Expand Down
9 changes: 5 additions & 4 deletions src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ export const Popover = ({ children, ...props }: RadixPopover.PopoverProps) => {

const Trigger = styled(RadixPopover.Trigger)`
width: fit-content;
background: transparent;
font: inherit;
color: inherit;
background: inherit;
border: none;
`;

interface TriggerProps extends RadixPopover.PopoverTriggerProps {
anchor?: ReactNode;
}

const PopoverTrigger = ({ children, anchor, ...props }: TriggerProps) => {
const PopoverTrigger = ({ anchor, children, ...props }: TriggerProps) => {
return (
<>
<Trigger
asChild
{...props}
>
{children}
<div>{children}</div>
</Trigger>
{anchor && <RadixPopover.Anchor asChild>{anchor}</RadixPopover.Anchor>}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioGroup/RadioGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
disabled: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
icon: "table",
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
icon: "code",
label: "Queries",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
icon: "code-in-square",
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
},
};

export const Default = {
export const Playground = {
args: {
icon: "table",
selected: false,
Expand Down
4 changes: 2 additions & 2 deletions src/components/SplitButton/SplitButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const menuItems: Array<Menu> = [
},
{
icon: "code",
iconDir: "left",
iconDir: "start",
label: "Content1",
},
{
Expand All @@ -34,7 +34,7 @@ const menuItems: Array<Menu> = [
},
{
icon: "code",
iconDir: "right",
iconDir: "end",
label: "Content2",
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/SplitButton/SplitButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const menuItems: Array<Menu> = [
},
{
icon: "code",
iconDir: "left",
iconDir: "start",
label: "Content1",
},
{
Expand All @@ -42,7 +42,7 @@ const menuItems: Array<Menu> = [
},
{
icon: "code",
iconDir: "right",
iconDir: "end",
label: "Content2",
},
{
Expand Down
Loading

0 comments on commit 0a72be6

Please sign in to comment.