Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Merge 06c6dfd into 34cb591
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Quach committed Mar 20, 2019
2 parents 34cb591 + 06c6dfd commit a521801
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
28 changes: 21 additions & 7 deletions src/components/Icon/styles/Icon.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const css = `
position: relative;
width: ${config.size}px;
${adjustIconScale()};
&.is-center {
margin-left: auto;
margin-right: auto;
Expand Down Expand Up @@ -69,8 +71,6 @@ const css = `
height: 100%;
max-width: 100%;
width: 100%;
${adjust24To20Scale()};
}
circle,
Expand Down Expand Up @@ -127,14 +127,28 @@ function makeStateColorStyles(): string {
)
}

function adjust24To20Scale(): string {
function adjust20IconScale(scale): string {
return `
&[height="24"],
&[width="24"],
&[viewBox*="24"] {
transform: scale(${24 / 20});
${bem.element('icon')} {
svg {
&[height="20"],
&[width="20"],
&[viewBox*="20"] {
transform: scale(${scale});
}
}
}
`
}

// Scales older 20x20 icons to have the same base size as the newer
// 24x24 set. This allows them to have a consistent visual size when
// rendered into their `div` container.

function adjustIconScale(): string {
return `
${adjust20IconScale(20 / 24)};
`
}

export default css
1 change: 0 additions & 1 deletion src/icons/checkmark.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/icons/small-paperclip.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion stories/Icon.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { select } from '@storybook/addon-knobs'
import { Flexy, Icon, Text } from '../src/index.js'
import iconList from '../src/components/Icon/icons'
import styled from '../src/components/styled'
Expand Down Expand Up @@ -41,10 +42,28 @@ const IconWrapper = styled('div')`
`

stories.add('icons', () => {
const size = select(
'size',
{
10: 10,
12: 12,
13: 13,
14: 14,
16: 16,
18: 18,
20: 20,
24: 24,
32: 32,
48: 48,
52: 52,
},
20
)

const icons = Object.keys(iconList).map(i => (
<WrapperUI key={i}>
<IconWrapper>
<Icon name={i} key={i} center />
<Icon name={i} key={i} size={size} center />
</IconWrapper>
<TextWrapper size="12">{i}</TextWrapper>
</WrapperUI>
Expand Down

0 comments on commit a521801

Please sign in to comment.