Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into page-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Jul 18, 2019
2 parents 084bd69 + b586afb commit 7d3e8e0
Show file tree
Hide file tree
Showing 35 changed files with 524 additions and 226 deletions.
10 changes: 1 addition & 9 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
# General code owners
* @GoOz @ptbrowne @y-lohse

# GoOz is responsible for CSS/Stylus files
*.css @GoOz
*.styl @GoOz

# cpatchane and ptbrowne for React components
*.js @cpatchane @ptbrowne @y-lohse
*.jsx @cpatchane @ptbrowne @y-lohse
* @ptbrowne @y-lohse
1 change: 1 addition & 0 deletions docs/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'../react/Checkbox/index.jsx',
'../react/Field/index.jsx',
'../react/Input/index.jsx',
'../react/InputGroup/index.jsx',
'../react/Label/index.jsx',
'../react/Radio/index.jsx',
'../react/SelectBox/SelectBox.jsx',
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build:css:all": "yarn build:css && yarn build:css:utils",
"build:css": "env CSSMODULES=false stylus -c --include stylus -o dist/cozy-ui.min.css stylus/cozy-ui/build.styl --use ./node_modules/autoprefixer-stylus --with \"{ browsers: ['last 2 versions'] }\"",
"build:css:utils": "env CSSMODULES=false stylus -c --include stylus -o dist/cozy-ui.utils.min.css stylus/cozy-ui/utils.styl --use ./node_modules/autoprefixer-stylus --with \"{ browsers: ['last 2 versions'] }\"",
"build:css:app": "env CSSMODULES=false stylus -c --include stylus -o build/styleguide/app.css stylus/cozy-ui/build.styl --use ./node_modules/autoprefixer-stylus --with \"{ browsers: ['last 2 versions'] }\"",
"build:css:kss": "env CSSMODULES=false stylus -c --include stylus -o build/styleguide/app.css stylus/cozy-ui/build.styl --use ./node_modules/autoprefixer-stylus --with \"{ browsers: ['last 2 versions'] }\"",
"build:doc": "npm-run-all 'build:doc:*'",
"build:doc:config": "copyfiles -u 1 docs/*.md docs/_config.yml build",
"build:doc:kss": "kss --destination build/styleguide --title 'Cozy-UI Styleguide' --source stylus --builder node_modules/michelangelo/kss_styleguide/custom-template --homepage styleguide.md --css app.css",
Expand All @@ -32,8 +32,8 @@
"palette": "scripts/make-palette.sh",
"prebuild:css": "mkdir -p dist/ && stylus -C node_modules/normalize.css/normalize.css node_modules/normalize.css/normalize.styl",
"prebuild:css:utils": "mkdir -p dist/",
"prebuild:css:app": "mkdir -p build/styleguide && stylus -C node_modules/normalize.css/normalize.css node_modules/normalize.css/normalize.styl",
"prebuild:doc:kss": "run-s clean:doc:kss build:css:app",
"prebuild:css:kss": "mkdir -p build/styleguide && stylus -C node_modules/normalize.css/normalize.css node_modules/normalize.css/normalize.styl",
"prebuild:doc:kss": "run-s clean:doc:kss build:css:kss",
"prepare": "yarn release",
"prepush": "[[ $(git rev-parse --abbrev-ref HEAD) != 'gh-pages' ]] && yarn lint || true",
"release": "npm-run-all --parallel sprite palette && yarn transpile",
Expand All @@ -54,8 +54,8 @@
"*.css"
],
"devDependencies": {
"@babel/cli": "7.4.4",
"@babel/core": "7.4.5",
"@babel/cli": "7.5.5",
"@babel/core": "7.5.5",
"@material-ui/core": "3.9.3",
"@semantic-release/changelog": "2.1.2",
"@semantic-release/git": "5.0.0",
Expand Down Expand Up @@ -86,7 +86,7 @@
"jest-cli": "24.8.0",
"kss": "3.0.0-beta.25",
"kss-webpack-plugin": "1.3.1",
"lodash": "4.17.11",
"lodash": "4.17.13",
"michelangelo": "https://github.com/cozy/michelangelo.git",
"mini-css-extract-plugin": "0.6.0",
"nodemon": "1.19.1",
Expand Down Expand Up @@ -181,7 +181,6 @@
},
"globals": {
"__ALLOW_HTTP__": false,
"__TARGET__": "browser",
"cozy": {}
},
"testURL": "http://localhost/",
Expand Down
1 change: 0 additions & 1 deletion react/AppLinker/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ As it uses the render props pattern, it is flexible and can be used to build com
anchor.

```
window.__TARGET__ = 'web';
<AppLinker slug='banks' href='http://dalailama-banks.mycozy.cloud'>{
({ onClick, href, name }) => (
Expand Down
4 changes: 1 addition & 3 deletions react/AppLinker/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global __TARGET__ */

import React from 'react'
import PropTypes from 'prop-types'
import {
Expand Down Expand Up @@ -33,7 +31,7 @@ export class AppLinker extends React.Component {
}

componentDidMount() {
if (__TARGET__ === 'mobile') {
if (isMobileApp()) {
this.checkAppAvailability()
}
}
Expand Down
2 changes: 1 addition & 1 deletion react/AppLinker/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('app icon', () => {
let spyConsoleError, openNativeFromNativeSpy, appSwitchMock

beforeEach(() => {
global.__TARGET__ = 'browser'
isMobileApp.mockReturnValue(false)
spyConsoleError = jest.spyOn(console, 'error')
spyConsoleError.mockImplementation(message => {
if (message.lastIndexOf('Warning: Failed prop type:') === 0) {
Expand Down
10 changes: 5 additions & 5 deletions react/Avatar/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ Show an avatar with initials
### Available sizes: xsmall, small, medium (default), large, xlarge
```
<div>
<div>
<div class="u-flex">
<Avatar size="xsmall" />
<Avatar text="CD" size="xsmall" />
<Avatar image="https://cozy.io/fr/images/cozy-logo_white.png" size="xsmall" />
</div>
<div>
<div class="u-flex">
<Avatar size="small" />
<Avatar text="CD" size="small" />
<Avatar image="https://cozy.io/fr/images/cozy-logo_white.png" size="small" />
</div>
<div>
<div class="u-flex">
<Avatar size="medium" />
<Avatar text="CD" size="medium" />
<Avatar image="https://cozy.io/fr/images/cozy-logo_white.png" size="medium" />
</div>
<div>
<div class="u-flex">
<Avatar size="large" />
<Avatar text="CD" size="large" />
<Avatar image="https://cozy.io/fr/images/cozy-logo_white.png" size="large" />
</div>
<div>
<div class="u-flex">
<Avatar size="xlarge" />
<Avatar text="CD" size="xlarge" />
<Avatar image="https://cozy.io/fr/images/cozy-logo_white.png" size="xlarge" />
Expand Down
12 changes: 7 additions & 5 deletions react/Avatar/styles.styl
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
@require '../../stylus/components/avatar'
@require '../../stylus/components/circle'

.c-avatar
@extend $circle
@extend $avatar

.c-avatar--xsmall
@extend $avatar--xsmall
@extend $circle--xsmall

.c-avatar--small
@extend $avatar--small
@extend $circle--small

.c-avatar--large
@extend $avatar--large
@extend $circle--large

.c-avatar--xlarge
@extend $avatar--xlarge
@extend $circle--xlarge

.c-avatar-initials
@extend $avatar-initials
@extend $circle-text

.c-avatar-image
@extend $avatar-image
21 changes: 21 additions & 0 deletions react/Circle/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@ Displays a simple circle with some text inside of it.
</Circle>
</div>
```

### Available sizes: xsmall, small, medium (default), large, xlarge
```
<div>
<div>
<Circle size="xsmall">Yo</Circle>
</div>
<div>
<Circle size="small">Yo</Circle>
</div>
<div>
<Circle size="medium">Yo</Circle>
</div>
<div>
<Circle size="large">Yo</Circle>
</div>
<div>
<Circle size="xlarge">Yo</Circle>
</div>
</div>
```
2 changes: 1 addition & 1 deletion react/Circle/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Circle = ({ children, backgroundColor, size, className }) => {

Circle.propTypes = {
backgroundColor: PropTypes.string,
size: PropTypes.oneOf(['medium']),
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge']),
className: PropTypes.string
}

Expand Down
13 changes: 11 additions & 2 deletions react/Circle/styles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
.c-circle
@extend $circle

.c-circle--medium
@extend $circle--medium
.c-circle--xsmall
@extend $circle--xsmall

.c-circle--small
@extend $circle--small

.c-circle--large
@extend $circle--large

.c-circle--xlarge
@extend $circle--xlarge

.c-circle-text
@extend $circle-text
2 changes: 1 addition & 1 deletion react/Field/styles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.o-side
position absolute
top 1.5rem
top 0.5rem
left 0
width 100%
max-width rem(512)
Expand Down
89 changes: 89 additions & 0 deletions react/InputGroup/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
### InputGroup with an appended text

```
const { Bold } = require('../Text');
const Input = require('../Input').default;
<form>
<div>
<InputGroup append={<Bold className="u-pr-1">text</Bold>}>
<Input placeholder="Placeholder" />
</InputGroup>
</div>
</form>
```

### InputGroup with a prepended text

```
const { Bold } = require('../Text');
const Input = require('../Input').default;
<form>
<div>
<InputGroup prepend={<Bold className="u-pl-1">text</Bold>}>
<Input placeholder="Placeholder" />
</InputGroup>
</div>
</form>
```

### InputGroup with an appended input

You will need to set a width to the side component, with a utility class for example.

```
const Input = require('../Input').default;
<form>
<div>
<InputGroup append={<Input placeholder="@domain.tld" className="u-w-4"/>}>
<Input placeholder="Email" />
</InputGroup>
</div>
</form>
```

### InputGroup with an appended select

You will need to set a width to the side component, with a utility class for example.

```
const SelectBox = require('../SelectBox').default;
const options = [
{ value: 'cozy.io', label: '.cozy.io' },
{ value: 'cozycloud.cc', label: '.cozycloud.cc' }
];
<form>
<div>
<InputGroup append={<SelectBox inset options={options} className="u-w-4" />}>
<Input placeholder="URL" />
</InputGroup>
</div>
</form>
```

### Full width InputGroup with an appended text

```
const { Bold } = require('../Text');
const Input = require('../Input').default;
<form>
<div>
<InputGroup fullwidth append={<Bold className="u-pr-1">text</Bold>}>
<Input placeholder="Placeholder" />
</InputGroup>
</div>
</form>
```

### Errored InputGroup with an appended text

```
const { Bold } = require('../Text');
const Input = require('../Input').default;
<form>
<div>
<InputGroup error append={<Bold className="u-pr-1">text</Bold>}>
<Input placeholder="Placeholder" />
</InputGroup>
</div>
</form>
```
57 changes: 57 additions & 0 deletions react/InputGroup/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { Component } from 'react'
import cx from 'classnames'
import PropTypes from 'prop-types'
import styles from './styles.styl'

class InputGroup extends Component {
constructor(props) {
super(props)
this.handleFocus = this.handleFocus.bind(this)
this.handleBlur = this.handleBlur.bind(this)
this.state = {
focused: false
}
}

handleFocus() {
this.setState({ focused: true })
}

handleBlur() {
this.setState({ focused: false })
}

render() {
const { children, prepend, append, error, fullwidth } = this.props
const { focused } = this.state
return (
<div
className={cx(styles['c-inputgroup'], {
[styles['c-inputgroup--error']]: error,
[styles['c-inputgroup--fullwidth']]: fullwidth,
[styles['c-inputgroup--focus']]: focused
})}
>
{prepend && (
<div className={styles['c-inputgroup-side']}>{prepend}</div>
)}
<div className={styles['c-inputgroup-main']}>{children}</div>
{append && <div className={styles['c-inputgroup-side']}>{append}</div>}
</div>
)
}
}

InputGroup.propTypes = {
prepend: PropTypes.object,
append: PropTypes.object,
error: PropTypes.bool,
fullwidth: PropTypes.bool
}

InputGroup.defaultProps = {
error: false,
fullwidth: false
}

export default InputGroup
22 changes: 22 additions & 0 deletions react/InputGroup/styles.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@require '../../stylus/components/forms'

.c-inputgroup
@extend $inputgroup

input
@extend $inputgroup-input

.c-inputgroup--focus
@extend $inputgroup--focus

.c-inputgroup--error
@extend $inputgroup--error

.c-inputgroup--fullwidth
@extend $inputgroup--fullwidth

.c-inputgroup-main
@extend $inputgroup-main

.c-inputgroup-side
@extend $inputgroup-side
Loading

0 comments on commit 7d3e8e0

Please sign in to comment.