Skip to content

Commit

Permalink
chore(projectcard)!: add metaIconName to allow custom meta icons and …
Browse files Browse the repository at this point in the history
…remove if not present
  • Loading branch information
Jin Lee committed Oct 28, 2022
1 parent fdea693 commit fa6787d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 77 deletions.
6 changes: 6 additions & 0 deletions .storybook/pages/CoursePlannerEdit/CoursePlannerEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export const CoursePlannerEdit = () => {
behavior="draggable"
buttonDropdownItems={projectCardMenuItemsWithDelete()}
meta="12 days"
metaIconName="event-note"
number={1}
numberAriaLabel="Project 1"
title="Longer project card title that wraps"
Expand All @@ -397,6 +398,7 @@ export const CoursePlannerEdit = () => {
behavior="draggable"
buttonDropdownItems={projectCardMenuItems()}
meta="12 days"
metaIconName="event-note"
number={indexState}
numberAriaLabel="Project 2"
title="Project card title"
Expand All @@ -410,6 +412,7 @@ export const CoursePlannerEdit = () => {
behavior="draggable"
buttonDropdownItems={projectCardMenuItems()}
meta="12 days"
metaIconName="event-note"
number={3}
numberAriaLabel="Project 3"
title="Project card title"
Expand All @@ -423,6 +426,7 @@ export const CoursePlannerEdit = () => {
behavior="draggable"
buttonDropdownItems={projectCardMenuItems()}
meta="12 days"
metaIconName="event-note"
number={4}
numberAriaLabel="Project 4"
title="Project card title"
Expand All @@ -437,6 +441,7 @@ export const CoursePlannerEdit = () => {
buttonDropdownItems={projectCardMenuItems()}
buttonDropdownPosition="top-left"
meta="12 days"
metaIconName="event-note"
number={5}
numberAriaLabel="Project 5"
title="Project card title"
Expand All @@ -451,6 +456,7 @@ export const CoursePlannerEdit = () => {
buttonDropdownItems={projectCardMenuItems()}
buttonDropdownPosition="top-left"
meta="12 days"
metaIconName="event-note"
number={6}
numberAriaLabel="Project 6"
title="Project card title"
Expand Down
22 changes: 7 additions & 15 deletions src/components/DragDrop/DragDrop.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ const InteractiveDragDrop = () => {
<ProjectCard
behavior="draggable"
meta="12 days"
metaIconName="event-note"
number={1}
numberAriaLabel="Project 1"
title="Longer project card title that wraps lorem ipsum dolor"
Expand All @@ -616,6 +617,7 @@ const InteractiveDragDrop = () => {
<ProjectCard
behavior="draggable"
meta="12 days"
metaIconName="event-note"
number={indexState}
numberAriaLabel="Project 2"
title="Project card title"
Expand All @@ -628,6 +630,7 @@ const InteractiveDragDrop = () => {
<ProjectCard
behavior="draggable"
meta="12 days"
metaIconName="event-note"
number={3}
numberAriaLabel="Project 3"
title="Project card title"
Expand All @@ -639,7 +642,8 @@ const InteractiveDragDrop = () => {
children: (
<ProjectCard
behavior="draggable"
meta="12 days"
meta="face icon"
metaIconName="face"
number={4}
numberAriaLabel="Project 4"
title="Project card title"
Expand All @@ -651,22 +655,10 @@ const InteractiveDragDrop = () => {
children: (
<ProjectCard
behavior="draggable"
meta="12 days"
meta="no icon"
number={5}
numberAriaLabel="Project 5"
title="Project card title"
/>
),
},
'item-6': {
title: 'Project #6',
children: (
<ProjectCard
behavior="draggable"
meta="12 days"
number={6}
numberAriaLabel="Project 6"
title="Project card title"
title="Hi"
/>
),
},
Expand Down
21 changes: 4 additions & 17 deletions src/components/DragDrop/__snapshots__/DragDrop.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1184,10 +1184,10 @@ exports[`<DragDrop /> Interactive story renders snapshot 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<use
xlink:href="test-file-stub#event-note"
xlink:href="test-file-stub#face"
/>
</svg>
12 days
face icon
</div>
</div>
</article>
Expand Down Expand Up @@ -1241,25 +1241,12 @@ exports[`<DragDrop /> Interactive story renders snapshot 1`] = `
<h3
class="heading heading--size-body-sm heading--neutral-strong project-card__title"
>
Project card title
Hi
</h3>
<div
class="project-card__meta"
>
<svg
aria-hidden="true"
class="icon project-card__meta-icon"
fill="currentColor"
height="0.875rem"
style="--icon-size: 0.875rem;"
width="0.875rem"
xmlns="http://www.w3.org/2000/svg"
>
<use
xlink:href="test-file-stub#event-note"
/>
</svg>
12 days
no icon
</div>
</div>
</article>
Expand Down
21 changes: 15 additions & 6 deletions src/components/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
} from '../..';
import type { HeadingElement } from '../Heading';

import type { IconName } from '../Icon';

export interface Props {
/**
* Determines type of clickable
Expand Down Expand Up @@ -53,6 +55,10 @@ export interface Props {
* Project card meta data (e.g. calendar)
*/
meta?: string;
/**
* Project card meta icon name. Should be appropriate EDS icon name.
*/
metaIconName?: IconName;
/**
* Project card number
*/
Expand All @@ -76,6 +82,7 @@ export const ProjectCard = ({
className,
title,
meta,
metaIconName,
number,
headingAs = 'h3',
buttonDropdownItems,
Expand Down Expand Up @@ -123,12 +130,14 @@ export const ProjectCard = ({
</Heading>
{meta && (
<div className={styles['project-card__meta']}>
<Icon
className={styles['project-card__meta-icon']}
name="event-note"
purpose="decorative"
size="0.875rem"
/>
{metaIconName && (
<Icon
className={styles['project-card__meta-icon']}
name={metaIconName}
purpose="decorative"
size="0.875rem"
/>
)}
{meta}
</div>
)}
Expand Down
39 changes: 0 additions & 39 deletions src/components/ProjectCard/__snapshots__/ProjectCard.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ exports[`<ProjectCard /> Default story renders snapshot 1`] = `
<div
class="project-card__meta"
>
<svg
aria-hidden="true"
class="icon project-card__meta-icon"
fill="currentColor"
height="0.875rem"
style="--icon-size: 0.875rem;"
width="0.875rem"
xmlns="http://www.w3.org/2000/svg"
>
<use
xlink:href="test-file-stub#event-note"
/>
</svg>
12 days
</div>
</div>
Expand Down Expand Up @@ -195,19 +182,6 @@ exports[`<ProjectCard /> Draggable story renders snapshot 1`] = `
<div
class="project-card__meta"
>
<svg
aria-hidden="true"
class="icon project-card__meta-icon"
fill="currentColor"
height="0.875rem"
style="--icon-size: 0.875rem;"
width="0.875rem"
xmlns="http://www.w3.org/2000/svg"
>
<use
xlink:href="test-file-stub#event-note"
/>
</svg>
12 days
</div>
</div>
Expand Down Expand Up @@ -372,19 +346,6 @@ exports[`<ProjectCard /> WithoutDropdown story renders snapshot 1`] = `
<div
class="project-card__meta"
>
<svg
aria-hidden="true"
class="icon project-card__meta-icon"
fill="currentColor"
height="0.875rem"
style="--icon-size: 0.875rem;"
width="0.875rem"
xmlns="http://www.w3.org/2000/svg"
>
<use
xlink:href="test-file-stub#event-note"
/>
</svg>
12 days
</div>
</div>
Expand Down

0 comments on commit fa6787d

Please sign in to comment.