Skip to content

Commit d051943

Browse files
committed
Merge remote-tracking branch 'Semantic-Org/master'
* Semantic-Org/master: (111 commits) fix(docs): fix usage of arrow function (Semantic-Org#1228) fix(Icon): Incorrect definition in typings (Semantic-Org#1225) fix(Button): fix `tabIndex` in typings (Semantic-Org#1224) fix(typings): add item prop to the DropdownProps (Semantic-Org#1223) docs(examples): add missing `key` props (Semantic-Org#1220) docs(changelog): update changelog [ci skip] 0.64.4 feat(Form): add `inverted` prop (Semantic-Org#1218) fix(ComponentExample): use explicit babel presets (Semantic-Org#1219) style(Button): update typings and propTypes usage (Semantic-Org#1216) style(Embed): update typings and propTypes usage (Semantic-Org#1217) chore(package): support for jsnext:main (Semantic-Org#1210) style(Step): update typings, tests and propTypes usage (Semantic-Org#1203) fix(Portal): do not take focus after first render (Semantic-Org#1215) style(Table|mixed): update typings, tests and propTypes usage (Semantic-Org#1200) fix(Dropdown): use `item` instead of `as={Menu.Item}` (Semantic-Org#659) fix(Dropdown): respect `closeOnBlur={false}` (Semantic-Org#1148) style(Breadcrumb): update typings and propTypes usage (Semantic-Org#1209) style(Dimmer): update typings (Semantic-Org#1208) fix(Divider|FormInput): fix the broken typings (Semantic-Org#1179) ...
2 parents e413523 + d3b1acd commit d051943

File tree

277 files changed

+8110
-2044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+8110
-2044
lines changed

.babelrc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
{
22
"presets": [
3-
"es2015",
3+
"./build/preset-es2015",
44
"react",
55
"stage-1"
66
],
77
"plugins": [
8-
"lodash"
8+
"lodash",
9+
"transform-react-handled-props",
10+
["transform-react-remove-prop-types", {
11+
"mode": "wrap"
12+
}],
13+
["transform-runtime", {
14+
"polyfill": false,
15+
"regenerator": false
16+
}]
917
],
1018
"env": {
1119
"test": {

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"jsx-a11y/tabindex-no-positive": 1,
3838
"react/jsx-curly-spacing": 0,
3939
"react/sort-comp": 0,
40+
"semi": [2, "never"],
4041
"padded-blocks": [2, {
4142
"blocks": "never",
4243
"switches": "never",

.github/CONTRIBUTING.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CONTRIBUTING
1212
- [Workflow](#workflow)
1313
- [Create a Component](#create-a-component)
1414
- [Define _meta](#define-_meta)
15+
- [Using propTypes](#using-proptypes)
1516
- [Conformance Test](#conformance-test)
1617
- [Open A PR](#open-a-pr)
1718
- [Spec out the API](#spec-out-the-api)
@@ -126,7 +127,7 @@ class Dropdown extends Component {
126127
127128
### Define _meta
128129

129-
Every component has a static property called `_meta`. This object defines the component. The values here are used in `propTypes`, generated documentation, generated test cases, and some utilities.
130+
Every component has a static property called `_meta`. This object defines the component. The values here are used for generated documentation, generated test cases and some utilities.
130131

131132
Here's an example `_meta` object:
132133

@@ -136,9 +137,6 @@ import { META } from '../../lib'
136137
const _meta = {
137138
name: 'MyComponent',
138139
type: META.TYPES.MODULE,
139-
props: {
140-
pointing: ['bottom left', 'bottom right'],
141-
},
142140
}
143141
```
144142

@@ -162,6 +160,23 @@ class MyComponent {
162160
}
163161
```
164162

163+
### Using propTypes
164+
165+
Every component must have fully described `propTypes`.
166+
167+
```js
168+
import React, { PropTypes } from 'react'
169+
170+
function MyComponent(props) {
171+
return <div className={props.position}>{props.children}</div>
172+
}
173+
174+
MyComponent.propTypes = {
175+
children: PropTypes.node,
176+
position: PropTypes.oneOf(['left', 'right']),
177+
}
178+
```
179+
165180
### Conformance Test
166181

167182
Review [common tests](#common-tests) below. You should now add the [`isConformant()`](#isconformant-required) common test and get it to pass. This will validate the `_meta` and help you get your component off the ground.
@@ -176,7 +191,7 @@ This will also help with getting early feedback and smaller faster iterations on
176191

177192
Review the SUI documentation for the component. Spec out the component's proposed API. The spec should demonstrate how your component's API will support all the native SUI features. You can reference this [API proposal][7] for the Input.
178193

179-
Once we have solidified the component spec, it's time to write some code. The following sections cover everything you'll need to spec and build your awesome component.
194+
Once we have solidified the component spec, it's time to write some code. The following sections cover everything you'll need to spec and build your awesome component.
180195

181196
## API
182197

CHANGELOG.md

Lines changed: 266 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="http://semantic-org.github.io/Semantic-UI-React">
3-
<img height="128" width="128" src="https://cloud.githubusercontent.com/assets/5067638/17415622/7ac62496-5a3f-11e6-864e-217ad1d9e021.png">
3+
<img height="128" width="128" src="https://github.com/Semantic-Org/Semantic-UI-React/raw/master/docs/app/logo.png">
44
</a>
55
<p align="center">
66
The official <a href="http://semantic-ui.com">Semantic UI</a>
@@ -77,7 +77,7 @@ Issues labeled [`good first contribution`][21] are a great way to ease into deve
7777

7878
### [Missing Components][17]
7979

80-
We're seeking component parity with Semantic UI, plus some addons. There is an issue for every missing component, labeled [`enhancement` `help wanted`][17]. Just comment on the issue you'd like to take.
80+
We're seeking component parity with Semantic UI, plus some addons. There is an issue for every missing component, labeled [`new component`][17]. Just comment on the issue you'd like to take.
8181

8282
### [Help Wanted Label][4]
8383

@@ -115,7 +115,6 @@ Any other issue labeled [`help wanted`][4] is ready for a PR.
115115
| ✓ Reveal | | | Sticky | |
116116
| ✓ Segment | | | Tab | |
117117
| ✓ Step | | | Transition | |
118-
| | | | | |
119118

120119
## Releasing
121120

@@ -153,7 +152,7 @@ Big thanks to our [contributors][20], especially:
153152
[14]: https://github.com/Semantic-Org/Semantic-UI-React/issues
154153
[15]: #
155154
[16]: http://technologyadvice.com/careers
156-
[17]: https://github.com/Semantic-Org/Semantic-UI-React/issues?q=is%3Aopen+label%3A%22help+wanted%22+label%3Aenhancement
155+
[17]: https://github.com/Semantic-Org/Semantic-UI-React/issues?q=is%3Aissue+is%3Aopen+label%3A%22new+component%22
157156
[18]: https://github.com/Semantic-Org/Semantic-UI-React/blob/master/CHANGELOG.md
158157
[19]: https://github.com/Semantic-Org/Semantic-UI-React/issues?q=is%3Aopen+RFC+label%3ARFC
159158
[20]: https://github.com/Semantic-Org/Semantic-UI-React/graphs/contributors

build/preset-es2015.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const options = process.env.BABEL_ENV === 'es' ? { modules: false } : {}
2+
3+
module.exports = {
4+
presets: [
5+
['es2015', options],
6+
],
7+
}

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ machine:
1010
test:
1111
pre:
1212
- npm run lint
13+
- npm run tsd:lint
1314
post:
1415
- bash <(curl -s https://codecov.io/bash)

docs/app/Components/ComponentDoc/ComponentExample.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import copyToClipboard from 'copy-to-clipboard'
88
import { exampleContext, repoURL } from 'docs/app/utils'
99
import { Divider, Grid, Icon, Header, Menu } from 'src'
1010
import Editor from 'docs/app/Components/Editor/Editor'
11-
import babelrc from '.babelrc'
1211

1312
const babelConfig = {
14-
presets: [...babelrc.presets],
13+
presets: ['es2015', 'react', 'stage-1'],
1514
}
1615

1716
const showCodeStyle = {
@@ -118,6 +117,7 @@ export default class ComponentExample extends Component {
118117
}
119118

120119
renderSourceCode = _.debounce(() => {
120+
const { examplePath } = this.props
121121
const { sourceCode } = this.state
122122
// Heads Up!
123123
//
@@ -129,27 +129,39 @@ export default class ComponentExample extends Component {
129129
const LODASH = require('lodash')
130130
const REACT = require('react')
131131
const SEMANTIC_UI_REACT = require('semantic-ui-react')
132+
let COMMON
132133
/* eslint-enable no-unused-vars */
133134

134135
// Should use an AST transform here... oh well :/
135136
// Rewrite the example file into an IIFE that returns a component
136137
// which can be rendered in this ComponentExample's render() method
137138

138139
// rewrite imports to const statements against the UPPERCASE module names
139-
const imports = _.get(/(import[\s\S]*from[\s\S]*['"]\n)/.exec(sourceCode), '[1]', '')
140+
const imports = _.get(/(^import[\s\S]*from[\s\S]*['"]\n)/.exec(sourceCode), '[1]', '')
140141
.replace(/[\s\n]+/g, ' ') // normalize spaces and make one line
141142
.replace(/ import/g, '\nimport') // one import per line
142143
.split('\n') // split lines
143-
.filter(l => l.trim() !== '') // remove empty lines
144-
.map(l => {
145-
const defaultImport = _.get(/import\s+(\w+)/.exec(l), '[1]')
146-
const destructuredImports = _.get(/import.*({[\s\w,}]+)\s+from/.exec(l), '[1]')
147-
const module = _.snakeCase(_.get(/import.*from\s+['"]([\w\-_]+)/.exec(l), '[1]', '')).toUpperCase()
148-
149-
return _.compact([
150-
defaultImport && `const ${defaultImport} = ${module}`,
151-
destructuredImports && `const ${destructuredImports} = ${module}`,
152-
]).join('\n')
144+
.filter(Boolean) // remove empty lines
145+
.map(l => { // rewrite imports to const statements
146+
const [
147+
defaultImport,
148+
destructuredImports,
149+
_module,
150+
] = _.tail(/import\s+([\w]+)?(?:\s*,\s*)?({[\s\w,]+})?\s+from\s+['"](?:.*\/)?([\w\-_]+)['"]/.exec(l))
151+
152+
const module = _.snakeCase(_module).toUpperCase()
153+
154+
if (module === 'COMMON') {
155+
const componentPath = examplePath.split(__PATH_SEP__).splice(0, 2).join(__PATH_SEP__)
156+
COMMON = require(`docs/app/Examples/${componentPath}/common`)
157+
}
158+
159+
const constStatements = []
160+
if (defaultImport) constStatements.push(`const ${defaultImport} = ${module}`)
161+
if (destructuredImports) constStatements.push(`const ${destructuredImports} = ${module}`)
162+
constStatements.push('\n')
163+
164+
return constStatements.join('\n')
153165
})
154166
.join('\n')
155167

@@ -233,29 +245,29 @@ export default class ComponentExample extends Component {
233245
<Divider horizontal>
234246
<Menu text>
235247
<Menu.Item
236-
active={copied || error} // to show the color
248+
active={copied || !!error} // to show the color
237249
color={copied ? 'green' : color}
238250
onClick={this.copyJSX}
239251
icon={!copied && 'copy'}
240252
content={copied ? 'Copied!' : 'Copy'}
241253
/>
242254
<Menu.Item
243-
active={error} // to show the color
255+
active={!!error} // to show the color
244256
color={color}
245257
icon='refresh'
246258
content='Reset'
247259
onClick={this.resetJSX}
248260
/>
249261
<Menu.Item
250-
active={error} // to show the color
262+
active={!!error} // to show the color
251263
color={color}
252264
icon='github'
253265
content='Edit'
254266
href={ghEditHref}
255267
target='_blank'
256268
/>
257269
<Menu.Item
258-
active={error} // to show the color
270+
active={!!error} // to show the color
259271
color={color}
260272
icon='bug'
261273
content='Issue'

docs/app/Components/ComponentDoc/ComponentProps.js

Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import React, { Component, PropTypes } from 'react'
33

44
import { Label, Table } from 'src'
55

6-
const descriptionExtraStyle = {
7-
fontSize: '0.95em',
8-
color: '#777',
9-
}
10-
116
/**
127
* Displays a table of a Component's PropTypes.
138
*/
@@ -25,26 +20,9 @@ export default class ComponentProps extends Component {
2520
meta: PropTypes.object,
2621
}
2722

28-
state = {
29-
showEnumsFor: {},
30-
}
31-
32-
toggleEnumsFor = (prop) => () => {
33-
this.setState({
34-
showEnumsFor: {
35-
...this.state.showEnumsFor,
36-
[prop]: !this.state.showEnumsFor[prop],
37-
},
38-
})
39-
}
23+
renderName = item => <code>{item.name}</code>
4024

41-
renderName = (item) => <code>{item.name}</code>
42-
43-
requiredRenderer = (item) => {
44-
if (!item.required) return null
45-
46-
return <Label size='mini' color='red' circular>required</Label>
47-
}
25+
requiredRenderer = item => item.required && <Label size='mini' color='red' circular>required</Label>
4826

4927
renderDefaultValue = (item) => {
5028
let defaultValue = _.get(item, 'defaultValue.value')
@@ -62,49 +40,28 @@ export default class ComponentProps extends Component {
6240
)
6341
}
6442

65-
renderEnums = (item) => {
66-
const { showEnumsFor } = this.state
67-
const { meta } = this.props
68-
69-
if (item.type.indexOf('enum') === -1) return null
43+
renderFunctionSignature = (item) => {
44+
if (item.type !== '{func}') return
7045

71-
const values = meta.props[item.name]
72-
const truncateAt = 30
46+
const params = _.filter(item.tags, { title: 'param' })
47+
const paramSignature = params
48+
.map(param => `${param.name}: ${param.type.name}`)
49+
.join(', ')
7350

74-
if (!values) return null
51+
const paramDescriptions = params.map(param => (
52+
<div style={{ color: '#888' }} key={param.name}>
53+
<strong>{param.name}</strong> - {param.description}
54+
</div>
55+
))
7556

76-
// show all if there are few
77-
if (values.length < truncateAt) {
78-
return (
79-
<p style={descriptionExtraStyle}>
80-
<strong>Enums: </strong>
81-
{values.join(', ')}
82-
</p>
83-
)
84-
}
57+
const signature = <pre><code>{item.name}({paramSignature})</code></pre>
8558

86-
// add button to show more when there are many values and it is not toggled
87-
if (!showEnumsFor[item.name]) {
88-
return (
89-
<p style={descriptionExtraStyle}>
90-
<strong>Enums: </strong>
91-
<a style={{ cursor: 'pointer' }} onClick={this.toggleEnumsFor(item.name)}>
92-
Show all {values.length}
93-
</a>
94-
<div>{values.slice(0, truncateAt - 1).join(', ')}...</div>
95-
</p>
96-
)
97-
}
98-
99-
// add "show more" button when there are many
10059
return (
101-
<p style={descriptionExtraStyle}>
102-
<strong>Enums: </strong>
103-
<a style={{ cursor: 'pointer' }} onClick={this.toggleEnumsFor(item.name)}>
104-
Show less
105-
</a>
106-
<div>{values.join(', ')}</div>
107-
</p>
60+
<div>
61+
<strong>Signature:</strong>
62+
{signature}
63+
{paramDescriptions}
64+
</div>
10865
)
10966
}
11067

@@ -124,11 +81,13 @@ export default class ComponentProps extends Component {
12481
name,
12582
type,
12683
value,
84+
tags: _.get(config, 'docBlock.tags'),
12785
required: config.required,
12886
defaultValue: config.defaultValue,
12987
description: description && description.split('\n').map(l => ([l, <br key={l} />])),
13088
}
13189
}), 'name')
90+
13291
return (
13392
<Table data={content} className='very basic compact'>
13493
<Table.Header>
@@ -145,13 +104,11 @@ export default class ComponentProps extends Component {
145104
<Table.Row key={item.name}>
146105
<Table.Cell>{this.renderName(item)}</Table.Cell>
147106
<Table.Cell>{this.requiredRenderer(item)}</Table.Cell>
148-
<Table.Cell>
149-
{item.type}
150-
</Table.Cell>
107+
<Table.Cell>{item.type}</Table.Cell>
151108
<Table.Cell>{this.renderDefaultValue(item.defaultValue)}</Table.Cell>
152109
<Table.Cell>
153110
{item.description && <p>{item.description}</p>}
154-
{this.renderEnums(item)}
111+
{this.renderFunctionSignature(item)}
155112
</Table.Cell>
156113
</Table.Row>
157114
))}

docs/app/Components/IconSearch/IconSearch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class IconSearch extends Component {
7575
renderIconColumn = (name) => (
7676
<Popup
7777
key={name}
78-
mouseOverDelay={500}
78+
mouseEnterDelay={500}
7979
inverted
8080
hoverable={false}
8181
size='mini'

docs/app/Examples/addons/Select/Types/SelectExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { Select } from 'semantic-ui-react'
33

44
import { countryOptions } from '../common'
5-
// [{ value: 'af', flag: 'af', text: 'Afghanistan' }, ...{}]
5+
// [{ key: 'af', value: 'af', flag: 'af', text: 'Afghanistan' }, ...{}]
66

77
const SelectExample = () => (
88
<Select placeholder='Select your country' options={countryOptions} />

0 commit comments

Comments
 (0)