-
Notifications
You must be signed in to change notification settings - Fork 2
feat(Icon): introduce 'bordered' and 'circular' variants #85
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
src/components/Icon/iconRules.ts
Outdated
boxShadow: '0 0 0 0.1em rgba(0,0,0,.1) inset', | ||
width: '2em', | ||
height: '2em', | ||
...(circular ? { borderRadius: '500em' } : { verticalAlign: 'baseline' }), |
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 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 ?
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.
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
andborderColor
variables to further customize Icon's appearance, splitcircular
frombordered
. 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?
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.
...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.
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.
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 = [ |
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.
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 = [ |
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.
As above, let's use iconNames
here as well.
] | ||
|
||
const IconExampleBordered = () => ( | ||
<div>{examples.map(iconName => <Icon key={iconName} name={iconName} bordered />)}</div> |
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.
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> |
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.
As above, let's inline the Icons instead of mapping over a list.
src/components/Icon/iconRules.ts
Outdated
boxShadow: '0 0 0 0.1em rgba(0,0,0,.1) inset', | ||
width: '2em', | ||
height: '2em', | ||
...(circular ? { borderRadius: '500em' } : { verticalAlign: 'baseline' }), |
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.
...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' |
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 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.
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.
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', |
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.
Are this going to be dependent on the size prop in the future?
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.
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?
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.
Sure, makes sense. Thanks!
Icon, 'bordered' and 'circular' variants
This variants are necessary to introduce border to icons - with 'circular' being an option to introduce rounded border.
TODO
API Proposal
bordered: boolean
circular: boolean