-
Notifications
You must be signed in to change notification settings - Fork 8
docs: icon collection 문서 추가 #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae5a8ed
docs: 아이콘 페이지 추가
Sh031224 6a79024
docs: 아이콘 클립보드 복사 수정
Sh031224 b6ab420
docs: 아이콘 문서 페이지 수정
Sh031224 dfa34ff
chore: icon 스크립트 수정
Sh031224 a8db65f
docs: docs animation 수정
Sh031224 ec2479e
chore: 주석 수정
Sh031224 9668b90
docs: 아이콘 문서 간격 조정
Sh031224 d4ecd96
Update packages/wds-icon/src/icon-logo-instagram-color.tsx
Sh031224 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
docs/src/app/(with-lnb)/docs/foundations/base-material/icons/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import CustomRenderProvider from '@/features/docs/components/custom-render/provider'; | ||
| import CustomRenderSummary from '@/features/docs/components/custom-render/summary'; | ||
| import FoundationsIcons from '@/features/docs/components/foundations/icons'; | ||
| import { createMetadata } from '@/helpers/metadata'; | ||
|
|
||
| import type { Metadata } from 'next'; | ||
|
|
||
| const TITLE = 'Icons'; | ||
| const DESCRIPTION = | ||
| '원티드의 아이콘은 기능이나 콘텐츠를 시각적으로 표현하는 요소로, 사용자가 인터페이스를 빠르게 탐색할 수 있도록 돕습니다.'; | ||
|
|
||
| export const metadata: Metadata = createMetadata({ | ||
| title: TITLE, | ||
| description: DESCRIPTION, | ||
| image: '/foundations/Thumbnails.png', | ||
| }); | ||
|
|
||
| const IconsPage = () => { | ||
| return ( | ||
| <> | ||
| <CustomRenderSummary title={TITLE} description={DESCRIPTION} /> | ||
|
|
||
| <CustomRenderProvider> | ||
| <FoundationsIcons /> | ||
| </CustomRenderProvider> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default IconsPage; |
173 changes: 173 additions & 0 deletions
173
docs/src/features/docs/components/foundations/icons/collections/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| import { | ||
| Box, | ||
| ContentBadge, | ||
| FlexBox, | ||
| IconButton, | ||
| Popover, | ||
| PopoverContent, | ||
| PopoverTrigger, | ||
| Typography, | ||
| WithInteraction, | ||
| } from '@wanteddev/wds'; | ||
| import * as Icons from '@wanteddev/wds-icon'; | ||
| import { useCallback } from 'react'; | ||
| import { camelCase } from 'change-case'; | ||
|
|
||
| import { breakWordStyle } from '@/styles/text'; | ||
|
|
||
| import { getKeywords } from '../helpers'; | ||
|
|
||
| import { | ||
| iconDetailWrapperStyle, | ||
| iconGridStyle, | ||
| iconItemStyle, | ||
| iconPopoverWrapperStyle, | ||
| } from './style'; | ||
|
|
||
| import type { MouseEvent } from 'react'; | ||
|
|
||
| type IconItem = { | ||
| name: string; | ||
| description: string; | ||
| }; | ||
|
|
||
| type Props = { | ||
| icons: Array<IconItem>; | ||
| }; | ||
|
|
||
| const Collections = ({ icons }: Props) => { | ||
| const createSvg = useCallback((target: HTMLElement) => { | ||
| const svgElement = target | ||
| .closest('[data-role="icon-detail-popover"]') | ||
| ?.querySelector('[data-role="icon-component-for-download"]'); | ||
|
|
||
| if (!svgElement) return; | ||
|
|
||
| const cloned = svgElement.cloneNode(true) as SVGSVGElement; | ||
| cloned.removeAttribute('style'); | ||
| cloned.removeAttribute('class'); | ||
|
|
||
| if (!cloned.getAttribute('xmlns')) { | ||
| cloned.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); | ||
| } | ||
|
|
||
| const svgString = new XMLSerializer().serializeToString(cloned); | ||
|
|
||
| return svgString.replaceAll('currentColor', '#171719'); | ||
| }, []); | ||
|
|
||
| const handleDownloadSvg = useCallback( | ||
| (name: string) => (e: MouseEvent) => { | ||
| const svgString = createSvg(e.target as HTMLElement); | ||
|
|
||
| if (!svgString) return; | ||
|
|
||
| const blob = new Blob([svgString], { type: 'image/svg+xml' }); | ||
| const url = URL.createObjectURL(blob); | ||
|
|
||
| const a = document.createElement('a'); | ||
| a.href = url; | ||
| a.download = `${camelCase(name.replace('Icon', ''))}.svg`; | ||
| a.click(); | ||
|
|
||
| URL.revokeObjectURL(url); | ||
| }, | ||
| [createSvg], | ||
| ); | ||
|
|
||
| if (icons.length === 0) return null; | ||
|
|
||
| return ( | ||
| <> | ||
| <Box sx={iconGridStyle}> | ||
| {icons.map((icon) => { | ||
| const IconComponent = Icons[icon.name as keyof typeof Icons]; | ||
|
|
||
| return ( | ||
| <Popover key={icon.name}> | ||
| <PopoverTrigger> | ||
| <WithInteraction variant="light"> | ||
| <FlexBox | ||
| flexDirection="column" | ||
| alignItems="center" | ||
| gap="12px" | ||
| as="button" | ||
| type="button" | ||
| aria-label={`Show detail ${icon.name}`} | ||
| sx={iconItemStyle} | ||
| > | ||
| <IconComponent aria-hidden /> | ||
| </FlexBox> | ||
| </WithInteraction> | ||
| </PopoverTrigger> | ||
|
|
||
| <PopoverContent | ||
| variant="custom" | ||
| sx={{ | ||
| padding: '20px 24px 24px', | ||
| }} | ||
| data-role="icon-detail-popover" | ||
| wrapperProps={{ sx: iconPopoverWrapperStyle }} | ||
| > | ||
| <FlexBox flexDirection="column" gap="16px" flex="1"> | ||
| <FlexBox gap="12px" justifyContent="space-between"> | ||
| <Typography | ||
| variant="headline2" | ||
| weight="bold" | ||
| color="semantic.label.normal" | ||
| sx={breakWordStyle} | ||
| > | ||
| {camelCase(icon.name.replace('Icon', ''))} | ||
| </Typography> | ||
|
|
||
| <IconButton | ||
| aria-label={`Download ${icon.name} svg`} | ||
| size={20} | ||
| onClick={handleDownloadSvg(icon.name)} | ||
| > | ||
| <Icons.IconDownload aria-hidden /> | ||
| </IconButton> | ||
| </FlexBox> | ||
|
|
||
| <FlexBox sx={iconDetailWrapperStyle}> | ||
| <IconComponent | ||
| data-role="icon-component-for-download" | ||
| aria-hidden | ||
| /> | ||
| </FlexBox> | ||
|
|
||
| {getKeywords(icon.description).length > 0 && ( | ||
| <FlexBox gap="12px" flexDirection="column"> | ||
| <Typography | ||
| color="semantic.label.neutral" | ||
| variant="label1" | ||
| weight="medium" | ||
| > | ||
| Keyword | ||
| </Typography> | ||
|
|
||
| <FlexBox flexWrap="wrap" gap="6px"> | ||
| {getKeywords(icon.description).map((keyword, i) => ( | ||
| <ContentBadge | ||
| color="neutral" | ||
| size="xsmall" | ||
| variant="solid" | ||
| key={i} | ||
| > | ||
| {keyword} | ||
| </ContentBadge> | ||
| ))} | ||
| </FlexBox> | ||
| </FlexBox> | ||
| )} | ||
| </FlexBox> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ); | ||
| })} | ||
| </Box> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Collections; |
65 changes: 65 additions & 0 deletions
65
docs/src/features/docs/components/foundations/icons/collections/style.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { addOpacity, css, respondTo } from '@wanteddev/wds'; | ||
|
|
||
| import type { Theme } from '@wanteddev/wds'; | ||
|
|
||
| export const iconGridStyle = (theme: Theme) => css` | ||
| display: grid; | ||
| grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); | ||
| gap: 12px; | ||
|
|
||
| ${respondTo(theme.breakpoint.sm)} { | ||
| grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); | ||
| } | ||
| `; | ||
|
|
||
| export const iconItemStyle = (theme: Theme) => css` | ||
| padding: 20px; | ||
| width: 100%; | ||
| border-radius: 12px; | ||
| aspect-ratio: 1/1; | ||
| border: none; | ||
| background-color: transparent; | ||
| cursor: pointer; | ||
| font-size: 20px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| box-shadow: inset 0 0 0 1px ${theme.semantic.line.normal.alternative}; | ||
| transition: box-shadow 0.15s ease; | ||
|
|
||
| &[aria-expanded='true'] { | ||
| box-shadow: inset 0 0 0 1px | ||
| ${addOpacity(theme.semantic.primary.normal, theme.opacity[16])}; | ||
|
|
||
| & > [wds-component='with-interaction'] { | ||
| background-color: ${theme.semantic.primary.normal}; | ||
| opacity: 0.06; | ||
| } | ||
| } | ||
|
|
||
| ${respondTo(theme.breakpoint.sm)} { | ||
| padding: 16px; | ||
| } | ||
| `; | ||
|
|
||
| export const iconDetailWrapperStyle = (theme: Theme) => css` | ||
| width: 100%; | ||
| height: 80px; | ||
| flex-shrink: 0; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border-radius: 10px; | ||
| font-size: 24px; | ||
| box-shadow: inset 0 0 0 1px ${theme.semantic.line.normal.alternative}; | ||
| `; | ||
|
|
||
| export const iconPopoverWrapperStyle = css` | ||
| min-width: unset !important; | ||
| max-width: 100%; | ||
| width: 380px; | ||
| padding-inline: var(--layout-padding-inline); | ||
|
|
||
| ${respondTo('500px')} { | ||
| width: 100%; | ||
| } | ||
| `; |
18 changes: 18 additions & 0 deletions
18
docs/src/features/docs/components/foundations/icons/helpers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| export const isColorIcon = (name: string) => { | ||
| return name.endsWith('Color'); | ||
| }; | ||
|
|
||
| export const isNavigationIcon = (name: string) => { | ||
| return name.startsWith('IconNavigation'); | ||
| }; | ||
|
|
||
| export const isSolidIcon = (name: string) => { | ||
| return !isColorIcon(name) && !isNavigationIcon(name); | ||
| }; | ||
|
|
||
| export const getKeywords = (description: string) => { | ||
| const match = description.match(/키워드:\s*(.+)/); | ||
| if (!match) return []; | ||
|
|
||
| return match[1]?.split(',').map((keyword) => keyword.trim()) ?? []; | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description이null또는undefined일 경우 런타임 오류가 발생할 수 있습니다.icons.json에서description이 누락된 경우description.match()가TypeError를 발생시킬 수 있습니다.🛡️ 방어적 코드 제안
export const getKeywords = (description: string) => { + if (!description) return []; + const match = description.match(/키워드:\s*(.+)/); if (!match) return []; return match[1]?.split(',').map((keyword) => keyword.trim()) ?? []; };📝 Committable suggestion
🤖 Prompt for AI Agents