-
Notifications
You must be signed in to change notification settings - Fork 2
feat(Icon): introduce 'bordered' and 'circular' variants #85
Changes from 3 commits
4b7fe95
e15f049
f339689
6363807
215672f
30df07c
4f8b1bd
dc2fa25
b9b291b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import { Icon } from 'stardust' | ||
|
||
const examples = [ | ||
'chess rock', | ||
'book', | ||
'expand', | ||
'play', | ||
'stop', | ||
'calendar alternate outline', | ||
'coffee', | ||
'compass outline', | ||
'area chart', | ||
] | ||
|
||
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 commentThe 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 |
||
) | ||
|
||
export default IconExampleBordered |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
import { Icon } from 'stardust' | ||
|
||
const examples = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, let's use |
||
'chess rock', | ||
'book', | ||
'expand', | ||
'play', | ||
'stop', | ||
'calendar alternate outline', | ||
'coffee', | ||
'compass outline', | ||
'area chart', | ||
] | ||
|
||
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 commentThe 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. |
||
) | ||
|
||
export default IconExampleCircular |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,17 @@ const getIcon = (kind, name) => { | |
|
||
const getSize = size => `${sizes.get(size)}em` || '1em' | ||
|
||
const getBorderedStyles = circular => ({ | ||
lineHeight: '1', | ||
padding: '0.5em 0', | ||
boxShadow: '0 0 0 0.1em rgba(0,0,0,.1) inset', | ||
width: '2em', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Sure, makes sense. Thanks! |
||
height: '2em', | ||
...(circular ? { borderRadius: '500em' } : { verticalAlign: 'baseline' }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 So, while I totally see your point, it seems that with current set of props we should mix bordered and circular aspects in the
@mnajdova, @levithomason, what are your thoughts about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed. Let's not do that. The circular prop should be enough to cause the icon to appear circular.
Also agree. Let's get this in and then iterate. |
||
}) | ||
|
||
const iconRules = { | ||
root: ({ color, kind, name, size }) => { | ||
root: ({ props: { color, kind, name, size, bordered, circular } }) => { | ||
const { fontFamily, content } = getIcon(kind, name) | ||
return { | ||
fontFamily, | ||
|
@@ -56,6 +65,8 @@ const iconRules = { | |
boxSizing: 'inherit', | ||
background: '0 0!important', | ||
}, | ||
|
||
...((bordered || circular) && getBorderedStyles(circular)), | ||
} | ||
}, | ||
} | ||
|
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.