diff --git a/components.json b/components.json index 1aedb8f2..c508e217 100644 --- a/components.json +++ b/components.json @@ -148,5 +148,8 @@ ], "message": [ "./packages/message/index.js" + ], + "card": [ + "./packages/card/index.js" ] } diff --git a/examples/assets/images/hamburger.png b/examples/assets/images/hamburger.png new file mode 100644 index 00000000..b31a246d Binary files /dev/null and b/examples/assets/images/hamburger.png differ diff --git a/examples/docs/card.md b/examples/docs/card.md new file mode 100644 index 00000000..392b583c --- /dev/null +++ b/examples/docs/card.md @@ -0,0 +1,119 @@ + + + + +## 基础用法 +包含标题, 内容和操作 + + + + + + 卡片名称 + 操作按钮 + + + {{'列表内容 ' + o }} + + + + + +```html + + + 卡片名称 + 操作按钮 + + + {{'列表内容 ' + o }} + + +``` + +## 简单卡片 +卡片可以只有内容区域 + + + + + + {{'列表内容 ' + o }} + + + + + +```html + + + {{'列表内容 ' + o }} + + +``` + + +## 带图片 +可配置定义更丰富的内容展示 + + + + + + + + 好吃的汉堡 + {{ currentDate }} + + 操作按钮 + + + + + +```html + + + + + 好吃的汉堡 + {{ currentDate }} + + 操作按钮 + + +``` + +## API +| 参数 | 说明 | 类型 | 可选值 | 默认值 | +|---------- |-------- |---------- |------------- |-------- | +| header | 设置 header,也可以通过 `slot#header` 传入 DOM | string| | | +| body-style | 设置 body 的样式| object| | { padding: '20px' } | diff --git a/examples/nav.config.json b/examples/nav.config.json index ed886eeb..6ac5a360 100644 --- a/examples/nav.config.json +++ b/examples/nav.config.json @@ -92,6 +92,12 @@ "name": "加载 (loading)", "title": "loading 加载", "description": "加载数据时显示" + }, + { + "path": "/card", + "name": "卡片 (card)", + "title": "card 卡片", + "description": "将信息聚合在卡片容器中展示" } ] }, diff --git a/packages/card/cooking.conf.js b/packages/card/cooking.conf.js new file mode 100644 index 00000000..c5f2a79e --- /dev/null +++ b/packages/card/cooking.conf.js @@ -0,0 +1,31 @@ +var cooking = require('cooking'); +var path = require('path'); + +cooking.set({ + entry: { + index: path.join(__dirname, 'index.js') + }, + dist: path.join(__dirname, 'lib'), + template: false, + format: 'umd', + moduleName: 'ElCard', + extractCSS: 'style.css', + + extends: ['vue', 'saladcss'] +}); + +cooking.add('resolve.alias', { + 'main': path.join(__dirname, '../../src'), + 'packages': path.join(__dirname, '../../packages') +}); + +cooking.add('externals', { + vue: { + root: 'Vue', + commonjs: 'vue', + commonjs2: 'vue', + amd: 'vue' + } +}); + +module.exports = cooking.resolve(); diff --git a/packages/card/index.js b/packages/card/index.js new file mode 100644 index 00000000..b1e85bec --- /dev/null +++ b/packages/card/index.js @@ -0,0 +1,7 @@ +const Card = require('./src/main'); + +Card.install = function(Vue) { + Vue.component(Card.name, Card); +}; + +module.exports = Card; diff --git a/packages/card/package.json b/packages/card/package.json new file mode 100644 index 00000000..c34580fe --- /dev/null +++ b/packages/card/package.json @@ -0,0 +1,15 @@ +{ + "name": "el-card", + "version": "0.0.0", + "description": "A card component for Vue.js.", + "keywords": [ + "element", + "vue", + "component" + ], + "main": "./lib/index.js", + "repository": "https://github.com/element-component/element/tree/master/packages/card", + "author": "elemefe", + "license": "MIT", + "dependencies": {} +} diff --git a/packages/card/src/main.vue b/packages/card/src/main.vue new file mode 100644 index 00000000..3422ebcb --- /dev/null +++ b/packages/card/src/main.vue @@ -0,0 +1,18 @@ + + + + {{ header }} + + + + + + + + diff --git a/packages/theme-default/src/card.css b/packages/theme-default/src/card.css new file mode 100644 index 00000000..c080c43c --- /dev/null +++ b/packages/theme-default/src/card.css @@ -0,0 +1,23 @@ +@charset "UTF-8"; +@import "./common/var.css"; + +@component-namespace el { + @b card { + border: 1px solid var(--card-border-color); + border-radius: var(--card-border-radius); + background-color: #fff; + overflow: hidden; + box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, .12), + 0px 0px 6px 0px rgba(0, 0, 0, .04); + + @e header { + padding: calc(var(--card-padding) - 2) var(--card-padding); + border-bottom: 1px solid var(--card-border-color); + box-sizing: border-box; + } + + @e body { + padding: var(--card-padding); + } + } +} diff --git a/packages/theme-default/src/common/var.css b/packages/theme-default/src/common/var.css index 1eaf6941..34823f89 100644 --- a/packages/theme-default/src/common/var.css +++ b/packages/theme-default/src/common/var.css @@ -353,4 +353,10 @@ --dropdown-menu-box-shadow: 0 0 6px 0 rgba(0,0,0,.12), 0 2px 4px 0 rgba(0,0,0,.12); --dropdown-menuItem-hover-fill: #e5e9f2; --dropdown-menuItem-hover-color: #475669; + + /*Card + --------------------------*/ + --card-border-color: var(--disabled-border-base); + --card-border-radius: 4px; + --card-padding: 20px; } diff --git a/packages/theme-default/src/index.css b/packages/theme-default/src/index.css index 806a0476..9076f792 100644 --- a/packages/theme-default/src/index.css +++ b/packages/theme-default/src/index.css @@ -32,3 +32,4 @@ @import "./row.css"; @import "./col.css"; @import "./spinner.css"; +@import "./card.css";