Skip to content

Commit

Permalink
[DST-64]: Ref: unify the used chev icon over all components (#3228)
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaAbdellateef authored Aug 7, 2023
1 parent 502a64a commit 478906c
Show file tree
Hide file tree
Showing 9 changed files with 9,992 additions and 3,372 deletions.
15 changes: 8 additions & 7 deletions packages/components/src/Accordion/AccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import { mergeProps } from '@react-aria/utils';
import { TreeState } from '@react-stately/tree';
import { Node } from '@react-types/shared';

import { SVG, useClassNames, useStateProps } from '@marigold/system';
import { useClassNames, useStateProps } from '@marigold/system';

import { useAccordionItem } from './useAccordionItem';
import { Button } from '../Button';
import { ChevronDown, ChevronUp } from '../Chevron';

// props
// ----------------
export interface AccordionItemProps {
item: Node<object>;
state: TreeState<object>;
Expand All @@ -17,6 +20,8 @@ export interface AccordionItemProps {
size?: string;
}

// component
// ---------------
export const AccordionItem = ({
item,
state,
Expand Down Expand Up @@ -69,13 +74,9 @@ export const AccordionItem = ({
>
{title}
{!expanded ? (
<SVG viewBox="0 0 24 24" aria-hidden={true}>
<path d="M5.97563 7.125L12 13.1363L18.0244 7.125L19.875 8.97563L12 16.8506L4.125 8.97563L5.97563 7.125Z" />
</SVG>
<ChevronUp className="h3 w-6" />
) : (
<SVG viewBox="0 0 24 24" aria-hidden={true}>
<path d="M5.97563 16.8506L12 10.8394L18.0244 16.8506L19.875 15L12 7.125L4.125 15L5.97563 16.8506Z" />
</SVG>
<ChevronDown className="h3 w-6" />
)}
</Button>
</FocusRing>
Expand Down
14 changes: 14 additions & 0 deletions packages/components/src/Chevron/ChevronDown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { forwardRef } from 'react';
import { SVG, SVGProps as SVGPropsType } from '@marigold/system';

interface SVGProps extends SVGPropsType {
className?: string;
}

export const ChevronDown = forwardRef<SVGSVGElement, SVGProps>(
({ className, ...props }, ref) => (
<SVG className={className} {...props} viewBox="0 0 24 24" ref={ref}>
<path d="M5.97563 7.125L12 13.1363L18.0244 7.125L19.875 8.97563L12 16.8506L4.125 8.97563L5.97563 7.125Z" />
</SVG>
)
);
14 changes: 14 additions & 0 deletions packages/components/src/Chevron/ChevronLeft.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { forwardRef } from 'react';
import { SVG, SVGProps as SVGPropsType } from '@marigold/system';

interface SVGProps extends SVGPropsType {
className?: string;
}

export const ChevronLeft = forwardRef<SVGSVGElement, SVGProps>(
({ className, ...props }, ref) => (
<SVG className={className} {...props} viewBox="0 0 24 24" ref={ref}>
<path d="M16.8506 18.0244L10.8394 12L16.8506 5.97563L15 4.125L7.125 12L15 19.875L16.8506 18.0244Z" />
</SVG>
)
);
14 changes: 14 additions & 0 deletions packages/components/src/Chevron/ChevronRight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { forwardRef } from 'react';
import { SVG, SVGProps as SVGPropsType } from '@marigold/system';

interface SVGProps extends SVGPropsType {
className?: string;
}

export const ChevronRight = forwardRef<SVGSVGElement, SVGProps>(
({ className, ...props }, ref) => (
<SVG className={className} {...props} viewBox="0 0 24 24" ref={ref}>
<path d="M7.125 18.0244L13.1363 12L7.125 5.97563L8.97563 4.125L16.8506 12L8.97563 19.875L7.125 18.0244Z" />
</SVG>
)
);
14 changes: 14 additions & 0 deletions packages/components/src/Chevron/ChevronUp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { forwardRef } from 'react';
import { SVG, SVGProps as SVGPropsType } from '@marigold/system';

interface SVGProps extends SVGPropsType {
className?: string;
}

export const ChevronUp = forwardRef<SVGSVGElement, SVGProps>(
({ className, ...props }, ref) => (
<SVG className={className} {...props} viewBox="0 0 24 24" ref={ref}>
<path d="M5.97563 16.8506L12 10.8394L18.0244 16.8506L19.875 15L12 7.125L4.125 15L5.97563 16.8506Z" />
</SVG>
)
);
4 changes: 4 additions & 0 deletions packages/components/src/Chevron/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './ChevronUp';
export * from './ChevronDown';
export * from './ChevronRight';
export * from './ChevronLeft';
5 changes: 2 additions & 3 deletions packages/components/src/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Input } from '../Input';
import { Button } from '../Button';

import { Item } from '@react-stately/collections';
import { ChevronDown } from '../Chevron';
import { WidthProp } from '@marigold/system';

export interface ComboBoxProps
Expand Down Expand Up @@ -101,9 +102,7 @@ export const ComboBox = ({
ref={buttonRef}
{...buttonProps}
>
<svg viewBox="0 0 20 20" fill="currentColor">
<path d="M5.97563 7.125L12 13.1363L18.0244 7.125L19.875 8.97563L12 16.8506L4.125 8.97563L5.97563 7.125Z" />
</svg>
<ChevronDown className="h-4 w-4" />
</Button>
}
/>
Expand Down
24 changes: 2 additions & 22 deletions packages/components/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useSelectState } from '@react-stately/select';
import { Item, Section } from '@react-stately/collections';
import type { AriaSelectProps } from '@react-types/select';
import { mergeProps, useObjectRef } from '@react-aria/utils';

import {
cn,
useClassNames,
Expand All @@ -26,26 +25,7 @@ import { FieldBase } from '../FieldBase';
import { ListBox } from '../ListBox';
import { messages } from './intl';
import { Popover, Tray } from '../Overlay';

// Select Icon
// ---------------
interface ChevronProps {
className: string;
}

const Chevron = ({ className }: ChevronProps) => (
<svg
className={className}
width={16}
height={16}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
>
<path strokeLinecap="round" strokeLinejoin="round" d="M19 9l-7 7-7-7" />
</svg>
);
import { ChevronDown } from '../Chevron';

// Props
// ---------------
Expand Down Expand Up @@ -176,7 +156,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
? state.selectedItem.rendered
: props.placeholder}
</div>
<Chevron className={classNames.icon} />
<ChevronDown className="h-4 w-4" />
</button>
{isSmallScreen ? (
<Tray state={state}>
Expand Down
Loading

2 comments on commit 478906c

@vercel
Copy link

@vercel vercel bot commented on 478906c Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marigold-storybook – ./

marigold-storybook-git-main-marigold.vercel.app
marigold-storybook-marigold.vercel.app
marigold-latest.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 478906c Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marigold-docs – ./

marigold-docs-git-main-marigold.vercel.app
marigold-docs-marigold.vercel.app
marigold-docs.vercel.app

Please sign in to comment.