-
Notifications
You must be signed in to change notification settings - Fork 55
Conversation
* generalize API for svg and font-based icons * remove 'svg' prop in IconSet example * add mechanism for providing font-based icons in theme * fix UTs * remove getExtraProps method * fix theme icons example in docs * generalize object and function types as icon descriptors * fix unit tests * address review comments
…react into feat/themable-icons
Codecov Report
@@ Coverage Diff @@
## master #260 +/- ##
==========================================
- Coverage 92.57% 92.19% -0.39%
==========================================
Files 62 61 -1
Lines 1131 1127 -4
Branches 168 147 -21
==========================================
- Hits 1047 1039 -8
- Misses 81 84 +3
- Partials 3 4 +1
Continue to review full report at Codecov.
|
src/lib/renderComponent.tsx
Outdated
const ElementType = getElementType({ defaultProps }, props) | ||
|
||
const stateAndProps = { ...state, ...props } | ||
const derivedProps = getExtraProps({ icons }) |
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.
It looks like you took old changes from #183.
getExtraProps
was removed.
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.
thanks for the heads up - this artefact had leaked in during merge, as there were lots of conflicts with master. Thanks a lot!
src/components/Icon/Icon.tsx
Outdated
@@ -120,22 +114,22 @@ class Icon extends UIComponent<Extendable<IIconProps>, any> { | |||
return <ElementType className={classes.root} {...accessibility.attributes.root} {...rest} /> | |||
} | |||
|
|||
renderSvgIcon(ElementType, classes, rest, accessibility): React.ReactNode { | |||
renderSvgIcon(ElementType, icons: ThemeIcons, classes, rest, accessibility): React.ReactNode { |
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.
public
or private
?
src/components/Icon/Icon.tsx
Outdated
renderComponent({ ElementType, classes, rest, accessibility, theme }) { | ||
const { icons = {} } = theme | ||
|
||
return icons[this.props.name] && icons[this.props.name].isSvg |
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.
I would prefer to access the array only once, store icons[this.props.name]
to a variable and pass it to renderSvgIcon()
instead of icons
@@ -6,6 +6,14 @@ export type Extendable<T> = T & { | |||
[key: string]: any | |||
} | |||
|
|||
export type ArgOf<T> = T extends (arg: infer TArg) => any ? TArg : never | |||
export type ResultOf<T> = T extends (...arg: any[]) => infer TResult ? TResult : never | |||
|
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.
+1
This PR represents accumulated changes from the following two (both were approved to merge):