From 39426022da71f2d07de1b9506f648090afbd21bb Mon Sep 17 00:00:00 2001 From: zy19940510 Date: Wed, 28 Oct 2020 16:55:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20button=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 11 +++ .prettierrc | 9 +++ package.json | 1 + src/packages/button/demo.vue | 53 ++++++++----- src/packages/button/index.scss | 141 +++++++++++++++++++++++++++++++-- src/packages/button/index.vue | 98 ++++++++++++++++++----- src/sites/mobile/App.vue | 21 ++--- src/styles/variables.scss | 51 ++++++++++-- 8 files changed, 329 insertions(+), 56 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..a0c1e7a45 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +**/*.html +**/*.txt +**/*.md +**/*.svg +**/*.ttf +**/*.woff +**/*.eot +package.json +lib/plugin/cli/site/doc/page +lib/plugin/cli/site/doc/view +node_modules diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..b77cefe16 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "singleQuote": true, + "semi": true, + "bracketSpacing": true, + "tabWidth": 2, + "printWidth": 150, + "useTabs": false, + "htmlWhitespaceSensitivity": "strict" +} \ No newline at end of file diff --git a/package.json b/package.json index d1e369e56..581866268 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "CHANGELOG.md" ], "scripts": { + "dev": "vue-cli-service serve", "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" diff --git a/src/packages/button/demo.vue b/src/packages/button/demo.vue index 83a384601..d060bbbbd 100644 --- a/src/packages/button/demo.vue +++ b/src/packages/button/demo.vue @@ -1,42 +1,57 @@ diff --git a/src/packages/button/index.scss b/src/packages/button/index.scss index ec285c121..2da029b68 100644 --- a/src/packages/button/index.scss +++ b/src/packages/button/index.scss @@ -1,10 +1,141 @@ .nut-button { - display: block; - background: $button-default-bg-color; + position: relative; + display: inline-block; + height: $button-default-height; + box-sizing: border-box; + margin: 0; + padding: 0; + line-height: $button-default-line-height; + font-size: $button-default-font-size; + text-align: center; + cursor: pointer; + transition: opacity 0.2s; + -webkit-appearance: none; + user-select: none; + touch-action: manipulation; + &::before { + position: absolute; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + background-color: $black; + border: inherit; + border-color: $black; + border-radius: inherit; + transform: translate(-50%, -50%); + opacity: 0; + content: ' '; + } + &:active::before { + opacity: 0.1; + } + + &--loading, + &--disabled { + &::before { + display: none; + } + } + &--default { color: $button-default-color; + background: $button-default-bg-color; + border: $button-border-width solid $button-default-border-color; + } + + &--primary { + color: $button-primary-color; + background: $button-primary-background-color; + border: $button-border-width solid transparent; + } + + &--info { + color: $button-info-color; + background: $button-info-background-color; + border: $button-border-width solid transparent; + } + + &--success { + color: $button-success-color; + background: $button-success-background-color; + border: $button-border-width solid transparent; + } + + &--danger { + color: $button-danger-color; + background: $button-danger-background-color; + border: $button-border-width solid transparent; + } + + &--warning { + color: $button-warning-color; + background: $button-warning-background-color; + border: $button-border-width solid transparent; + } + + &--plain { + background-color: $button-plain-background-color; + + &.van-button--primary { + color: $button-primary-background-color; + } + + &.van-button--success { + color: $button-success-background-color; + } + + &.van-button--danger { + color: $button-danger-background-color; + } + + &.van-button--warning { + color: $button-warning-background-color; + } + } + + &--large { + width: 100%; + height: $button-large-height; + } + + &--normal { + padding: 0 18px; font-size: $button-default-font-size; - line-height: $button-default-height; - height: $button-default-height; + } + + &--small { + height: $button-small-height; + padding: 0 $padding-xs; + font-size: $font-size-1; + } + + &__loading { + color: inherit; + font-size: inherit; + } + + &--block { + display: block; + width: 100%; + height: $button-block-height; + line-height: $button-block-line-height; + font-size: $font-size-3; + } + + &--disabled { + cursor: not-allowed; + opacity: $button-disabled-opacity; + } + + &--loading { + cursor: default; + } + + &--round { border-radius: $button-border-radius; - text-align: center; + } + + &--square { + border-radius: 0; + } } diff --git a/src/packages/button/index.vue b/src/packages/button/index.vue index 191cdb4fb..b7d20936c 100644 --- a/src/packages/button/index.vue +++ b/src/packages/button/index.vue @@ -1,41 +1,103 @@ diff --git a/src/sites/mobile/App.vue b/src/sites/mobile/App.vue index 060944cfe..bff1c867a 100644 --- a/src/sites/mobile/App.vue +++ b/src/sites/mobile/App.vue @@ -1,16 +1,16 @@