Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaffolding chalk #6643

Merged
merged 2 commits into from
Aug 23, 2017
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
10 changes: 6 additions & 4 deletions build/bin/gen-cssfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var fs = require('fs');
var path = require('path');
var Components = require('../../components.json');
var themes = [
'theme-default'
'theme-default',
'theme-chalk'
];
Components = Object.keys(Components);
var basepath = path.resolve(__dirname, '../../packages/');
Expand All @@ -16,16 +17,17 @@ function fileExists(filePath) {
}

themes.forEach((theme) => {
var indexContent = '@import "./base.css";\n';
var isSCSS = theme !== 'theme-default';
var indexContent = isSCSS ? '@import "./base.scss";\n' : '@import "./base.css";\n';
Components.forEach(function(key) {
if (['icon', 'option', 'option-group'].indexOf(key) > -1) return;
var fileName = key + '.css';
var fileName = key + (isSCSS ? '.scss' : '.css');
indexContent += '@import "./' + fileName + '";\n';
var filePath = path.resolve(basepath, theme, 'src', fileName);
if (!fileExists(filePath)) {
fs.writeFileSync(filePath, '', 'utf8');
console.log(theme, ' 创建遗漏的 ', fileName, ' 文件');
}
});
fs.writeFileSync(path.resolve(basepath, theme, 'src', 'index.css'), indexContent);
fs.writeFileSync(path.resolve(basepath, theme, 'src', isSCSS ? 'index.scss' : 'index.css'), indexContent);
});
4 changes: 4 additions & 0 deletions build/cooking.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ cooking.set({

cooking.add('output.filename', 'element-ui.common.js');
cooking.add('loader.js.exclude', config.jsexclude);
cooking.add('loader.scss', {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
});
cooking.add('vue.preserveWhitespace', false);
module.exports = cooking.resolve();
4 changes: 4 additions & 0 deletions build/cooking.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ cooking.set({

cooking.add('output.filename', '[name].js');
cooking.add('loader.js.exclude', config.jsexclude);
cooking.add('loader.scss', {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
});
cooking.add('vue.preserveWhitespace', false);
module.exports = cooking.resolve();
4 changes: 4 additions & 0 deletions build/cooking.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ cooking.set({

cooking.add('output.filename', 'index.js');
cooking.add('loader.js.exclude', config.jsexclude);
cooking.add('loader.scss', {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
});
cooking.add('vue.preserveWhitespace', false);
module.exports = cooking.resolve();
5 changes: 5 additions & 0 deletions build/cooking.demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ cooking.add('loader.md', {
loader: 'vue-markdown-loader'
});

cooking.add('loader.scss', {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
});

cooking.add(
'output.chunkFilename',
isProd ? '[name].[chunkhash:7].js' : '[name].js'
Expand Down
156 changes: 69 additions & 87 deletions examples/docs/en-US/button.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
<script>
import { addClass } from 'element-ui/src/utils/dom';
export default {
data() {
return {
isLoading: false,
isLoading2: false
};
},
methods: {
handleClick(event) {
console.log(event);
alert('button clicked!');
}
},
mounted() {
this.$nextTick(() => {
let demos = document.querySelectorAll('.source');
let thirdDemo = demos[2];
addClass(thirdDemo, 'intro-block');
});
}
}
</script>
<style>
.demo-box.demo-button {
.el-row {
Expand All @@ -42,30 +18,6 @@
}
}
}

.demo-box.demo-button .intro-block {
padding: 0;
}

.demo-button .intro-block .block {
padding: 30px 24px;
overflow: hidden;
border-bottom: solid 1px #EFF2F6;
&:last-child {
border-bottom: none;
}
}

.demo-button .intro-block .demonstration {
font-size: 14px;
color: #8492a6;
line-height: 44px;
}

.demo-button .intro-block .wrapper {
float: right;
margin-right: 20px;
}
</style>

## Button
Expand All @@ -77,55 +29,76 @@ Commonly used button.
::: demo Button provides 7 themes defined by the `type` attribute.

```html
<el-button>Default Button</el-button>
<el-button type="primary">Primary Button</el-button>
<el-button type="text">Text Button</el-button>
<div>
<el-button>Default</el-button>
<el-button type="primary">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
</div>

<div style="margin: 20px 0">
<el-button plain>Plain</el-button>
<el-button type="primary" plain>Primary</el-button>
<el-button type="success" plain>Success</el-button>
<el-button type="info" plain>Info</el-button>
<el-button type="warning" plain>Warning</el-button>
<el-button type="danger" plain>Danger</el-button>
</div>

<div>
<el-button round>Round</el-button>
<el-button type="primary" round>Primary</el-button>
<el-button type="success" round>Success</el-button>
<el-button type="info" round>Info</el-button>
<el-button type="warning" round>Warning</el-button>
<el-button type="danger" round>Danger</el-button>
</div>
```
:::

### Disabled Button

The `disableds` attribute determines if the button is disabled.
The `disabled` attribute determines if the button is disabled.

:::demo Use `disabled` attribute to determine whether a button is disabled. It accepts a `Boolean` value.

```html
<el-button :plain="true" :disabled="true">Default Button</el-button>
<el-button type="primary" disabled>Primary Button</el-button>
<el-button type="text" disabled>Text Button</el-button>
<div>
<el-button disabled>Default</el-button>
<el-button type="primary" disabled>Primary</el-button>
<el-button type="success" disabled>Success</el-button>
<el-button type="info" disabled>Info</el-button>
<el-button type="warning" disabled>Warning</el-button>
<el-button type="danger" disabled>Danger</el-button>
</div>

<div style="margin-top: 20px">
<el-button plain disabled>Plain</el-button>
<el-button type="primary" plain disabled>Primary</el-button>
<el-button type="success" plain disabled>Success</el-button>
<el-button type="info" plain disabled>Info</el-button>
<el-button type="warning" plain disabled>Warning</el-button>
<el-button type="danger" plain disabled>Danger</el-button>
</div>
```
:::

### Color Indication
### Text Button

Different colors represent different meanings.
Buttons without border and background.

:::demo Use `plain` attribute to create a plain button, and it accepts a `Boolean` value. You can assign different `type` to a plain button as mentioned above. **Note**: When using the plain button, you still can set `type` to `text`, but it makes no difference. A plain button will be styled like a `text button` by default.
:::demo
```html
<div class="block">
<span class="demonstration">Default</span>
<span class="wrapper">
<el-button type="success">Success</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
<el-button type="info">Info</el-button>
</span>
</div>
<div class="block">
<span class="demonstration">Hover to display color</span>
<span class="wrapper">
<el-button :plain="true" type="success">Success</el-button>
<el-button :plain="true" type="warning">Warning</el-button>
<el-button :plain="true" type="danger">Danger</el-button>
<el-button :plain="true" type="info">Info</el-button>
</span>
</div>
<el-button type="text">Text Button</el-button>
<el-button type="text" disabled>Text Button</el-button>
```
:::

### Icon Button

Use icons to add more meaning to Button. You can use icon alone to save some space, or with text together.
Use icons to add more meaning to Button. You can use icon alone to save some space, or use it with text.

:::demo Use the `icon` attribute to add icon. You can find the icon list in Element icon component. Adding icons to the right side of the text is achievable with an `<i>` tag. Custom icons can be used as well.

Expand Down Expand Up @@ -172,24 +145,33 @@ Click the button to load data, then the button displays a loading state.

Besides default size, Button component provides three additional sizes for you to choose among different scenarios.

:::demo Use attribute `size` to set additional sizes with `large`, `small` or `mini`.
:::demo Use attribute `size` to set additional sizes with `medium`, `small` or `mini`.

```html
<el-button type="primary" size="large">Large Button</el-button>
<el-button type="primary">Default Button</el-button>
<el-button type="primary" size="small">Small Button</el-button>
<el-button type="primary" size="mini">Mini Button</el-button>
<div>
<el-button>Default</el-button>
<el-button size="medium">Medium</el-button>
<el-button size="small">Small</el-button>
<el-button size="mini">Mini</el-button>
</div>
<div style="margin-top: 20px">
<el-button round>Default</el-button>
<el-button size="medium" round>Medium</el-button>
<el-button size="small" round>Small</el-button>
<el-button size="mini" round>Mini</el-button>
</div>
```
:::

### Attributes
| Attribute | Description | Type | Accepted values | Default |
|---------- |-------- |---------- |------------- |-------- |
| size | button size | string | large/small/mini | — |
| type | button type | string | primary/success/warning/danger/info/text | — |
| plain | determine whether it's a plain button | Boolean | — | false |
| loading | determine whether it's loading | Boolean | — | false |
| size | button size | string | large / small / mini | — |
| type | button type | string | primary / success / warning / danger / info / text | — |
| plain | determine whether it's a plain button | boolean | — | false |
| round | determine whether it's a round button | boolean | — | false |
| loading | determine whether it's loading | boolean | — | false |
| disabled | disable the button | boolean | — | false |
| icon | button icon, accepts an icon name of Element icon component | string | — | — |
| autofocus | same as native button's `autofocus` | boolean | — | false |
| native-type | same as native button's `type` | string | button/submit/reset | button |
| native-type | same as native button's `type` | string | button / submit / reset | button |
Loading