From bef818e9d3476e526f56254e271fb03457bd3e09 Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Tue, 29 Oct 2024 17:11:12 +0100 Subject: [PATCH] wip: add icon components --- src/components/icons.tsx | 252 +++++++----------------- src/stories/components/icon.stories.tsx | 140 +++++++++++++ 2 files changed, 216 insertions(+), 176 deletions(-) create mode 100644 src/stories/components/icon.stories.tsx diff --git a/src/components/icons.tsx b/src/components/icons.tsx index d9ea74f..dae5889 100644 --- a/src/components/icons.tsx +++ b/src/components/icons.tsx @@ -1,51 +1,29 @@ import { HTMLAttributes } from 'react' import { cx } from '@emotion/css' -export type IconBaseProps = { +export type IconProps = { filled?: boolean } & HTMLAttributes -type GetClassNameOptions = { - filled?: boolean - className?: string -} - -export function getClassName({ filled, className }: GetClassNameOptions) { - return cx( - 'material-symbols-rounded', - { 'material-symbols-rounded__filled': filled }, - 'text-[16px]', - className, - ) -} - -export const IconPlayArrow = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconPlayArrow = ({ className, filled, ...props }: IconProps) => ( play_arrow ) -export const IconUpload = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconUpload = ({ className, filled, ...props }: IconProps) => ( upload ) -export const IconAdmin = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconAdmin = ({ className, filled, ...props }: IconProps) => ( admin_panel_settings ) -export const IconDatabase = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconDatabase = ({ className, filled, ...props }: IconProps) => ( database @@ -55,7 +33,7 @@ export const IconRemoveOperator = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( remove_moderator @@ -65,33 +43,25 @@ export const IconNotifications = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( notifications ) -export const IconMoreVert = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconMoreVert = ({ className, filled, ...props }: IconProps) => ( more_vert ) -export const IconLogout = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconLogout = ({ className, filled, ...props }: IconProps) => ( logout ) -export const IconChevronLeft = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconChevronLeft = ({ className, filled, ...props }: IconProps) => ( chevron_left @@ -101,55 +71,43 @@ export const IconChevronRight = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( chevron_right ) -export const IconChevronDown = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconChevronDown = ({ className, filled, ...props }: IconProps) => ( keyboard_arrow_down ) -export const IconChevronUp = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconChevronUp = ({ className, filled, ...props }: IconProps) => ( keyboard_arrow_up ) -export const IconAdd = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconAdd = ({ className, filled, ...props }: IconProps) => ( add ) -export const IconEdit = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconEdit = ({ className, filled, ...props }: IconProps) => ( edit ) -export const IconGroup = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconGroup = ({ className, filled, ...props }: IconProps) => ( group ) -export const IconDownload = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconDownload = ({ className, filled, ...props }: IconProps) => ( download @@ -159,51 +117,43 @@ export const IconArrowTopRight = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( arrow_top_right ) -export const IconFileCopy = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconFileCopy = ({ className, filled, ...props }: IconProps) => ( file_copy ) -export const IconDelete = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconDelete = ({ className, filled, ...props }: IconProps) => ( delete ) -export const IconSend = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconSend = ({ className, filled, ...props }: IconProps) => ( send ) -export const IconPersonAdd = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconPersonAdd = ({ className, filled, ...props }: IconProps) => ( person_add ) -export const IconPerson = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconPerson = ({ className, filled, ...props }: IconProps) => ( person ) -export const IconCheck = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconCheck = ({ className, filled, ...props }: IconProps) => ( check @@ -213,7 +163,7 @@ export const IconLibraryAddCheck = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( library_add_check @@ -223,7 +173,7 @@ export const IconSelectCheckBox = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( select_check_box @@ -233,135 +183,103 @@ export const IconCheckBoxOutlineBlank = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( check_box_outline_blank ) -export const IconCheckCircle = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconCheckCircle = ({ className, filled, ...props }: IconProps) => ( check_circle ) -export const IconError = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconError = ({ className, filled, ...props }: IconProps) => ( error ) -export const IconWarning = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconWarning = ({ className, filled, ...props }: IconProps) => ( warning ) -export const IconInvitations = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconInvitations = ({ className, filled, ...props }: IconProps) => ( forward_to_inbox ) -export const IconWorkspaces = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconWorkspaces = ({ className, filled, ...props }: IconProps) => ( workspaces ) -export const IconFlag = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconFlag = ({ className, filled, ...props }: IconProps) => ( flag ) -export const IconClose = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconClose = ({ className, filled, ...props }: IconProps) => ( close ) -export const IconSchedule = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconSchedule = ({ className, filled, ...props }: IconProps) => ( schedule ) -export const IconClearAll = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconClearAll = ({ className, filled, ...props }: IconProps) => ( clear_all ) -export const IconOpenInNew = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconOpenInNew = ({ className, filled, ...props }: IconProps) => ( open_in_new ) -export const IconInfo = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconInfo = ({ className, filled, ...props }: IconProps) => ( info ) -export const IconSearch = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconSearch = ({ className, filled, ...props }: IconProps) => ( search ) -export const IconRefresh = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconRefresh = ({ className, filled, ...props }: IconProps) => ( refresh ) -export const IconSync = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconSync = ({ className, filled, ...props }: IconProps) => ( sync ) -export const IconGridView = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconGridView = ({ className, filled, ...props }: IconProps) => ( grid_view ) -export const IconArrowUpward = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconArrowUpward = ({ className, filled, ...props }: IconProps) => ( arrow_upward @@ -371,33 +289,25 @@ export const IconArrowDownward = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( arrow_downward ) -export const IconExpandMore = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconExpandMore = ({ className, filled, ...props }: IconProps) => ( expand_more ) -export const IconList = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconList = ({ className, filled, ...props }: IconProps) => ( list ) -export const IconHourglass = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconHourglass = ({ className, filled, ...props }: IconProps) => ( hourglass @@ -407,7 +317,7 @@ export const IconKeyboardArrowLeft = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( keyboard_arrow_left @@ -417,7 +327,7 @@ export const IconKeyboardArrowRight = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( keyboard_arrow_right @@ -427,7 +337,7 @@ export const IconKeyboardDoubleArrowRight = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( keyboard_double_arrow_right @@ -437,98 +347,88 @@ export const IconKeyboardDoubleArrowLeft = ({ className, filled, ...props -}: IconBaseProps) => ( +}: IconProps) => ( keyboard_double_arrow_left ) -export const IconFirstPage = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconFirstPage = ({ className, filled, ...props }: IconProps) => ( first_page ) -export const IconLastPage = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconLastPage = ({ className, filled, ...props }: IconProps) => ( last_page ) -export const IconHistory = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconHistory = ({ className, filled, ...props }: IconProps) => ( history ) -export const IconModeHeat = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconModeHeat = ({ className, filled, ...props }: IconProps) => ( mode_heat ) -export const IconSecurity = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconSecurity = ({ className, filled, ...props }: IconProps) => ( security ) -export const IconVisibility = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconVisibility = ({ className, filled, ...props }: IconProps) => ( visibility ) -export const IconTune = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconTune = ({ className, filled, ...props }: IconProps) => ( tune ) -export const IconHome = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconHome = ({ className, filled, ...props }: IconProps) => ( home ) -export const IconStacks = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconStacks = ({ className, filled, ...props }: IconProps) => ( stacks ) -export const IconCloudUpload = ({ - className, - filled, - ...props -}: IconBaseProps) => ( +export const IconCloudUpload = ({ className, filled, ...props }: IconProps) => ( cloud_upload ) -export const IconBolt = ({ className, filled, ...props }: IconBaseProps) => ( +export const IconBolt = ({ className, filled, ...props }: IconProps) => ( bolt ) + +type GetClassNameOptions = { + filled?: boolean + className?: string +} + +function getClassName({ filled, className }: GetClassNameOptions) { + return cx( + 'material-symbols-rounded', + { 'material-symbols-rounded__filled': filled }, + 'text-[16px]', + className, + ) +} diff --git a/src/stories/components/icon.stories.tsx b/src/stories/components/icon.stories.tsx new file mode 100644 index 0000000..1d5f128 --- /dev/null +++ b/src/stories/components/icon.stories.tsx @@ -0,0 +1,140 @@ +import { Meta, StoryObj } from '@storybook/react' +import cx from 'classnames' +import { + IconAdd, + IconAdmin, + IconArrowDownward, + IconArrowTopRight, + IconArrowUpward, + IconBolt, + IconCheck, + IconCheckBoxOutlineBlank, + IconCheckCircle, + IconChevronDown, + IconChevronLeft, + IconChevronRight, + IconChevronUp, + IconClearAll, + IconClose, + IconCloudUpload, + IconDatabase, + IconDelete, + IconDownload, + IconEdit, + IconError, + IconExpandMore, + IconFileCopy, + IconFirstPage, + IconFlag, + IconGridView, + IconGroup, + IconHistory, + IconHome, + IconHourglass, + IconInfo, + IconInvitations, + IconKeyboardArrowLeft, + IconKeyboardArrowRight, + IconKeyboardDoubleArrowLeft, + IconKeyboardDoubleArrowRight, + IconLastPage, + IconLibraryAddCheck, + IconList, + IconLogout, + IconModeHeat, + IconMoreVert, + IconNotifications, + IconOpenInNew, + IconPerson, + IconPersonAdd, + IconPlayArrow, + IconRefresh, + IconRemoveOperator, + IconSchedule, + IconSearch, + IconSecurity, + IconSelectCheckBox, + IconSend, + IconStacks, + IconSync, + IconTune, + IconUpload, + IconVisibility, + IconWarning, + IconWorkspaces, +} from '../../components' + +const meta: Meta = { + title: 'Components/Icon', +} + +export default meta +type Story = StoryObj + +export const Default: Story = { + render: () => ( +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ), +}