From 83372d798e61abe9babd379a73963f5c00311b67 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 18 Sep 2023 17:48:56 -0300 Subject: [PATCH] refine hasIcon prop --- components/Teaser/RenderSubject.tsx | 11 ++++------- styles/demo/hed/data/7.100.json | 6 ++++-- styles/demo/hed/icons/videoPlayerIcon.tsx | 2 +- styles/demo/hed/tokens/subject.ts | 7 ++++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/Teaser/RenderSubject.tsx b/components/Teaser/RenderSubject.tsx index f1d93c057..6ec25e30e 100644 --- a/components/Teaser/RenderSubject.tsx +++ b/components/Teaser/RenderSubject.tsx @@ -14,7 +14,6 @@ export type SubjectLayout = { color?: ColorTokens; enabled?: boolean; font_size?: [string, string]; - hasIcon?: boolean, iconComponent?: any line_height?: [string, string]; mb?: SpacingType; @@ -24,7 +23,6 @@ export type SubjectLayout = { export type RenderSubjectProps = { color?: ColorTokens | string; editable?: any; - hasIcon?: boolean, iconComponent?: any item?: any; layout?: LayoutProps; @@ -36,16 +34,15 @@ const RenderSubject = ({ item, layout, }: RenderSubjectProps) => { - const font_size = get(layout, 'subject.font_size', ['14px', '14px']) const line_height = get(layout, 'subject.line_height', ['16px', '16px']) const mb = get(layout, 'subject.mb', ['0px', '0px']) const subject_enabled = get(layout, 'subject.enabled', false) const subject_variant = get(layout, 'subject.variant', '') - const hasIcon = get(layout, 'subject.hasIcon', false) const iconComponent = get(layout, 'subject.iconComponent', false) let subject_value = get(item, 'subject', '') + let hasIcon = get(item, 'video', false) if (!subject_enabled) { return null @@ -85,10 +82,10 @@ const RenderSubject = ({ if (hasIcon) { return ( - {iconComponent()} + {iconComponent(item)} { +export const renderIcon = (props) => { return ( diff --git a/styles/demo/hed/tokens/subject.ts b/styles/demo/hed/tokens/subject.ts index 333f48486..c3fcc1e6f 100644 --- a/styles/demo/hed/tokens/subject.ts +++ b/styles/demo/hed/tokens/subject.ts @@ -9,7 +9,6 @@ export const SUBJECT_DEFAULT: LayoutProps['subject'] = { line_height: ['16px', '16px'], mb: ['4px', '4px'], variant: 'default', - hasIcon: true, iconComponent: renderIcon } export const SUBJECT_DEFAULT_FEATURED: LayoutProps['subject'] = { @@ -18,7 +17,8 @@ export const SUBJECT_DEFAULT_FEATURED: LayoutProps['subject'] = { font_size: ['12px', '16px'], line_height: ['16px', '16px'], mb: [1, 1], - variant: 'default' + variant: 'default', + iconComponent: renderIcon } export const SUBJECT_FILLED: LayoutProps['subject'] = { color: 'white', @@ -26,5 +26,6 @@ export const SUBJECT_FILLED: LayoutProps['subject'] = { font_size: ['16px', '16px'], line_height: ['18px', '18px'], mb: [1, 1], - variant: 'filled' + variant: 'filled', + iconComponent: renderIcon }