Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

feat(Icon): introduce 'bordered' and 'circular' variants #85

Merged
merged 9 commits into from
Jul 18, 2018

Conversation

kuzhelov
Copy link
Collaborator

@kuzhelov kuzhelov commented Jul 13, 2018

Icon, 'bordered' and 'circular' variants

This variants are necessary to introduce border to icons - with 'circular' being an option to introduce rounded border.

TODO

  • Feature tests
  • Conformance test
  • Minimal doc site example
  • Stardust base theme
  • Teams Light theme
  • Teams Dark theme
  • Teams Contrast theme
  • Confirm RTL usage
  • W3 accessibility check
  • Stardust accessibility check
  • Update glossary props table
    • updated for the component's props
  • Update the CHANGELOG.md

API Proposal

bordered: boolean

image

<Icon bordered name="..." />

circular: boolean

image

<Icon circular name="..." />

@codecov
Copy link

codecov bot commented Jul 13, 2018

Codecov Report

Merging #85 into master will increase coverage by <.01%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #85      +/-   ##
==========================================
+ Coverage   69.94%   69.94%   +<.01%     
==========================================
  Files          73       74       +1     
  Lines        1191     1198       +7     
  Branches      223      205      -18     
==========================================
+ Hits          833      838       +5     
- Misses        353      355       +2     
  Partials        5        5
Impacted Files Coverage Δ
src/components/Icon/iconVariables.ts 100% <100%> (ø)
src/components/Icon/Icon.tsx 100% <100%> (ø) ⬆️
src/components/Icon/iconRules.ts 90.47% <66.66%> (-9.53%) ⬇️

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 9e89994...b9b291b. Read the comment docs.

@kuzhelov kuzhelov changed the title feat(Icon): introduce bordered and circular variants feat(Icon): introduce 'bordered' and 'circular' variants Jul 13, 2018
boxShadow: '0 0 0 0.1em rgba(0,0,0,.1) inset',
width: '2em',
height: '2em',
...(circular ? { borderRadius: '500em' } : { verticalAlign: 'baseline' }),
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me that with this implementation, we cannot have circular icon without border. I think the current circular example, should be result of using the circular as well as the bordered props. What do you think @kuzhelov ?

Copy link
Collaborator Author

@kuzhelov kuzhelov Jul 16, 2018

Choose a reason for hiding this comment

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

actually, this question is a bit tricky. First of all, lets consider the fact that currently we have just one color prop that defines icon's color. Icon's background is transparent. With that being said, it turns out that there is no much value for us to introduce circular button without border - it won't have any visual difference for the client in comparison to the rectangular one.

So, while I totally see your point, it seems that with current set of props we should mix bordered and circular aspects in the circular prop. At the same time, to obtain more flexibility around styling, as well as for the sake of decoupling these aspects, I would suggest the following:

  • introduce backgroundColor and borderColor variables to further customize Icon's appearance, split circular from bordered. This is a step that could be considered in future, as long as we'll finish with the first round of necessary components.

@mnajdova, @levithomason, what are your thoughts about it?

Copy link
Member

Choose a reason for hiding this comment

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

...there is no much value for us to introduce circular button without border - it won't have any visual difference for the client...

Agreed. Let's not do that. The circular prop should be enough to cause the icon to appear circular.

...This is a step that could be considered in future, as long as we'll finish with the first round of necessary components.

Also agree. Let's get this in and then iterate.

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

This is a public facing change. Please update the CHANGELOG.md.

There should be an entry for this PR added under Features in UNRELEASED. See the instructions there.

import React from 'react'
import { Icon } from 'stardust'

const examples = [
Copy link
Member

Choose a reason for hiding this comment

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

nit: Since these are icon names, let's name this variable iconNames for more clarity.

import React from 'react'
import { Icon } from 'stardust'

const examples = [
Copy link
Member

Choose a reason for hiding this comment

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

As above, let's use iconNames here as well.

]

const IconExampleBordered = () => (
<div>{examples.map(iconName => <Icon key={iconName} name={iconName} bordered />)}</div>
Copy link
Member

Choose a reason for hiding this comment

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

For simplicity and readability in the example, let's not map over these. Instead, just use multiple Icon components. This makes a shorter example file and requires less thinking to understand what is happening. It also removes the need to use a key.

]

const IconExampleCircular = () => (
<div>{examples.map(iconName => <Icon key={iconName} name={iconName} circular />)}</div>
Copy link
Member

Choose a reason for hiding this comment

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

As above, let's inline the Icons instead of mapping over a list.

boxShadow: '0 0 0 0.1em rgba(0,0,0,.1) inset',
width: '2em',
height: '2em',
...(circular ? { borderRadius: '500em' } : { verticalAlign: 'baseline' }),
Copy link
Member

Choose a reason for hiding this comment

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

...there is no much value for us to introduce circular button without border - it won't have any visual difference for the client...

Agreed. Let's not do that. The circular prop should be enough to cause the icon to appear circular.

...This is a step that could be considered in future, as long as we'll finish with the first round of necessary components.

Also agree. Let's get this in and then iterate.

@@ -0,0 +1,18 @@
import React from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be a shorthand example (meaning to have this renamed to IconExampleCircular.shorthand.tsx). We don't really have other way for defining this using children, so I think this example should have just shorthand API. What do you think? Maybe @Bugaa92 will have the correct answer. If this is the case, that we should rename all examples that don't have a children, as a shorthand example. Correct me if I am wrong, because that is the approach I have taken on the examples regarding the Menu component.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it seems to be consistent with its semantics - let me do that

lineHeight: '1',
padding: '0.5em 0',
boxShadow: `0 0 0 0.1em ${borderColor || color || 'black'} inset`,
width: '2em',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are this going to be dependent on the size prop in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not absolutely sure, frankly - should made additional experiments with it. In either case, even if there would be any dependency between these two, it should be driven by visual looks provided by experiments. So far for the range of regular sizes that are usually used it seems to work fine. Lets address this point in a dedicated PR - what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, makes sense. Thanks!

@kuzhelov kuzhelov dismissed levithomason’s stale review July 18, 2018 10:55

requested changes are provided

@kuzhelov kuzhelov merged commit 5ac3ded into master Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants