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

add themeColor && Partial import Element #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
79 changes: 79 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = [
'Pagination',
'Dialog',
'Autocomplete',
'Dropdown',
'DropdownMenu',
'DropdownItem',
'Menu',
'Submenu',
'MenuItem',
'MenuItemGroup',
'Input',
'InputNumber',
'Radio',
'RadioGroup',
'RadioButton',
'Checkbox',
'CheckboxButton',
'CheckboxGroup',
'Switch',
'Select',
'Option',
'OptionGroup',
'Button',
'ButtonGroup',
'Table',
'TableColumn',
'DatePicker',
'TimeSelect',
'TimePicker',
'Popover',
'Tooltip',
'Breadcrumb',
'BreadcrumbItem',
'Form',
'FormItem',
'Tabs',
'TabPane',
'Tag',
'Tree',
'Alert',
'Slider',
'Icon',
'Row',
'Col',
'Upload',
'Progress',
'Spinner',
'Badge',
'Card',
'Rate',
'Steps',
'Step',
'Carousel',
'Scrollbar',
'CarouselItem',
'Collapse',
'CollapseItem',
'Cascader',
'ColorPicker',
'Transfer',
'Container',
'Header',
'Aside',
'Main',
'Footer',
'Timeline',
'TimelineItem',
'Link',
'Divider',
'Image',
'Calendar',
'Backtop',
'PageHeader',
'CascaderPanel',
'Avatar',
'Drawer',
'CollapseTransition'
]
2 changes: 1 addition & 1 deletion generator/templates/src/element-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Write your variables here. All available variables can be
found in element-ui/packages/theme-chalk/src/common/var.scss.
For example, to overwrite the theme color:
*/
$--color-primary: teal;
$--color-primary: <%= options.themeColor %>;

/* icon font path, required */
$--font-path: '~element-ui/lib/theme-chalk/fonts';
Expand Down
11 changes: 8 additions & 3 deletions generator/templates/src/plugins/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ Vue.use(Element, { locale })
Vue.use(Element)
<%_ } _%>
<%_ } else { _%>
import { Button } from 'element-ui'
import {
<%_ options.components.forEach(function(item){ _%>
<%= item %>,
<%_ }) _%>
} from 'element-ui'
<%_ if (options.lang !== 'zh-CN') { _%>
import lang from 'element-ui/lib/locale/lang/<%= options.lang %>'
import locale from 'element-ui/lib/locale'

locale.use(lang)
<%_ } _%>

Vue.use(Button)
<%_ options.components.forEach(function(item){ _%>
Vue.use(<%= item %>);
<%_ }) _%>
<%_ } _%>
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions prompts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
const localeList = require('./lang.js')
const componentList = require('./components.js')

module.exports = [
{
type: 'list',
name: 'lang',
message: 'Choose the locale you want to load',
choices: localeList.map(locale => ({
name: locale,
value: locale
})),
default: 'zh-CN'
},
{
type: 'list',
name: 'import',
Expand All @@ -11,6 +22,17 @@ module.exports = [
],
default: 'full',
},
{
when: answers => answers.import === 'partial',
type: 'checkbox',
name: 'components',
message: 'Choose the components you want to load',
choices: componentList.map(component => ({
name: component,
value: component,
checked: true
}))
},
{
when: answers => answers.import === 'full',
type: 'confirm',
Expand All @@ -19,13 +41,11 @@ module.exports = [
default: false,
},
{
type: 'list',
name: 'lang',
message: 'Choose the locale you want to load',
choices: localeList.map(locale => ({
name: locale,
value: locale
})),
default: 'zh-CN'
when: answers => answers.customTheme === true,
name: 'themeColor',
type: 'color',
message: 'Theme color',
description: 'This is used to change the system UI color around the app',
default: '#0073e8'
}
]