Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat: themable icons #260

Merged
merged 18 commits into from
Sep 21, 2018
Merged

feat: themable icons #260

merged 18 commits into from
Sep 21, 2018

Conversation

kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Sep 20, 2018

  • Update CHANGELOG.md

This PR represents accumulated changes from the following two (both were approved to merge):

kuzhelov-ms and others added 7 commits September 4, 2018 23:32
* 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
@kuzhelov kuzhelov changed the title Themable icons feat: themable icons Sep 20, 2018
@codecov
Copy link

codecov bot commented Sep 21, 2018

Codecov Report

Merging #260 into master will decrease coverage by 0.38%.
The diff coverage is 70%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/components/Icon/Icon.tsx 84% <70%> (-16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fe8cfd...6d1317d. Read the comment docs.

const ElementType = getElementType({ defaultProps }, props)

const stateAndProps = { ...state, ...props }
const derivedProps = getExtraProps({ icons })
Copy link
Member

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.

Copy link
Contributor Author

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!

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public or private?

renderComponent({ ElementType, classes, rest, accessibility, theme }) {
const { icons = {} } = theme

return icons[this.props.name] && icons[this.props.name].isSvg
Copy link
Member

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@kuzhelov kuzhelov merged commit 27ad112 into master Sep 21, 2018
@levithomason levithomason deleted the feat/themable-icons branch October 11, 2018 21:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants