Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Features
- Add Button `fluid` prop @Bugaa92 ([#6](https://github.com/stardust-ui/react/pull/6))
- Add Icon `disabled` prop @Bugaa92 ([#12](https://github.com/stardust-ui/react/pull/12))

<!--------------------------------[ v0.2.2 ]------------------------------- -->
## [v0.2.2](https://github.com/stardust-ui/react/tree/v0.2.2) (2018-07-24)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import { Icon } from '@stardust-ui/react'

const IconExampleDisabled = () => (
<div>
<Icon disabled name="users" size="big" />
<Icon disabled color="red" name="users" size="big" />
<Icon disabled color="orange" name="users" size="big" />
<Icon disabled color="yellow" name="users" size="big" />
</div>
)

export default IconExampleDisabled
15 changes: 15 additions & 0 deletions docs/src/examples/components/Icon/States/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const States = () => (
<ExampleSection title="States">
<ComponentExample
title="Disabled"
description="An icon can show it is currently unable to be interacted with."
examplePath="components/Icon/States/IconExampleDisabled"
/>
</ExampleSection>
)

export default States
2 changes: 2 additions & 0 deletions docs/src/examples/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react'
import Types from './Types'
import Variations from './Variations'
import States from './States'

const IconExamples = () => (
<div>
<Types />
<States />
<Variations />
</div>
)
Expand Down
15 changes: 14 additions & 1 deletion src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Icon extends UIComponent<any, any> {
'black',
]),

/** An icon can show it is currently unable to be interacted with. */
disabled: PropTypes.bool,

/** The type of font that needs to be used */
kind: PropTypes.string,

Expand All @@ -53,7 +56,17 @@ class Icon extends UIComponent<any, any> {
size: PropTypes.oneOf(['mini', 'tiny', 'small', 'large', 'big', 'huge', 'massive']),
}

static handledProps = ['as', 'bordered', 'circular', 'className', 'color', 'kind', 'name', 'size']
static handledProps = [
'as',
'bordered',
'circular',
'className',
'color',
'disabled',
'kind',
'name',
'size',
]

static defaultProps = {
as: 'i',
Expand Down
5 changes: 4 additions & 1 deletion src/components/Icon/iconRules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fontAwesomeIcons from './fontAwesomeIconRules'
import { disabledStyles } from '../../styles/customCSS'

const sizes = new Map([
['mini', 0.4],
Expand Down Expand Up @@ -38,7 +39,7 @@ const getBorderedStyles = (circular, borderColor, color) => ({
})

const iconRules = {
root: ({ props: { color, kind, name, size, bordered, circular }, variables: v }) => {
root: ({ props: { color, disabled, kind, name, size, bordered, circular }, variables: v }) => {
const { fontFamily, content } = getIcon(kind, name)
const iconColor = color || v.color

Expand Down Expand Up @@ -69,6 +70,8 @@ const iconRules = {
},

...((bordered || circular) && getBorderedStyles(circular, v.borderColor, iconColor)),

...(disabled && disabledStyles),
}
},
}
Expand Down
6 changes: 6 additions & 0 deletions src/styles/customCSS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CSSProperties } from 'react'

export const disabledStyles: CSSProperties = {
opacity: 0.45,
cursor: 'not-allowed',
}