Skip to content

Commit

Permalink
refactor(css): 组件theme样式移植core中处理
Browse files Browse the repository at this point in the history
  • Loading branch information
stbui committed Aug 5, 2018
1 parent c5ce417 commit 62801fa
Show file tree
Hide file tree
Showing 29 changed files with 242 additions and 109 deletions.
8 changes: 8 additions & 0 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ npm install -g @angular/cli

- https://nodejs.org/en/docs/
- https://github.com/angular/angular-cli/wiki

## Material Resources

- [Material Palette](https://www.materialpalette.com/)
- [Material Design Colors](https://www.materialui.co/colors)
- [Material Design Dark Color Palette](https://designguidelines.withgoogle.com/wearos/style/color.html)
- [Material Colors OSX Desktop App](https://github.com/romannurik/MaterialColorsApp)
- [official resource](https://material.io/design/)
19 changes: 9 additions & 10 deletions src/app/component/chat-widget/chat-widget.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
display: flex;
flex-direction: column;
box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
background: #2196f3;
}

.chat-box-hidden {
Expand Down Expand Up @@ -101,7 +100,7 @@

.chat-message-date {
font-size: 11px;
color: #8D898D;
color: #8d898d;
padding: 5px;
}

Expand All @@ -127,17 +126,17 @@
}

.chat-message-received .chat-message-text {
background: #B9D6F2;
background: #b9d6f2;
margin-left: 50px;
border-bottom-left-radius: 0;
}

.chat-message-received .chat-message-text:before {
position: absolute;
content: " ";
content: ' ';
left: -10px;
bottom: 0;
border-right: solid 10px #B9D6F2;
border-right: solid 10px #b9d6f2;
border-top: solid 10px transparent;
z-index: 0;
}
Expand All @@ -161,17 +160,17 @@
}

.chat-message-sent .chat-message-text {
background: #84DCCF;
background: #84dccf;
margin-right: 50px;
border-bottom-right-radius: 0;
}

.chat-message-sent .chat-message-text:after {
position: absolute;
content: " ";
content: ' ';
right: -10px;
bottom: 0;
border-left: solid 10px #84DCCF;
border-left: solid 10px #84dccf;
border-top: solid 10px transparent;
z-index: 0;
}
Expand Down Expand Up @@ -204,11 +203,11 @@
}

.red .chat-button {
background: #DD0031;
background: #dd0031;
}

.red .chat-box {
background: #DD0031;
background: #dd0031;
}

@media (min-width: 576px) {
Expand Down
22 changes: 22 additions & 0 deletions src/app/component/chat-widget/chat-widget.theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@mixin stbui-chat-widget-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);

.chat-box {
background-color: mat-color($primary);

&.mat-primary {
background-color: mat-color($primary);
}

&.mat-accent {
background-color: mat-color($accent);
}
&.mat-warn {
background-color: mat-color($warn);
}
}
}
19 changes: 19 additions & 0 deletions src/app/component/core/theming/_all-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import '../../pagination/pagination.theme';
@import '../../date-picker/date-picker.theme';
@import '../../notification/notification.theme';
@import '../../message/message.theme';
@import '../../dialog/dialog.theme';
@import '../../chat-widget/chat-widget.theme';
@import '../../tag-select/tag-select.theme';
@import '../../loading/loading.theme';

@mixin stbui-theme($theme) {
@include stbui-pagination-theme($theme);
@include stbui-date-picker-theme($theme);
@include stbui-chat-widget-theme($theme);
@include stbui-notification-theme($theme);
@include stbui-tag-select-theme($theme);
@include stbui-message-theme($theme);
@include stbui-dialog-theme($theme);
@include stbui-loading-theme($theme);
}
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/blue-grey-deep-orange.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-blue-grey, 700);
$accent: mat-palette($mat-deep-orange, 500, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/blue-orange.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-blue, 700);
$accent: mat-palette($mat-orange, 800, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/deeppurple-amber.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-deep-purple);
$accent: mat-palette($mat-amber, A200, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/indigo-pink.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-indigo, 500);
$accent: mat-palette($mat-pink, A200, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/orange-light-blue.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-orange, 800);
$accent: mat-palette($mat-light-blue, 600, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/pink-bluegrey.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-pink, 700, 500, 900);
$accent: mat-palette($mat-blue-grey, A200, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-dark-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/purple-green.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-purple, 700, 500, 800);
$accent: mat-palette($mat-green, A200, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-dark-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
13 changes: 13 additions & 0 deletions src/app/component/core/theming/prebuilt/teal-orange.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '~@angular/material/theming';
@import '../all-theme';

@include mat-core();

$primary: mat-palette($mat-teal, 700);
$accent: mat-palette($mat-orange, 800, A100, A400);
$warn: mat-palette($mat-red, 600);

$theme: mat-light-theme($primary, $accent, $warn);

@include angular-material-theme($theme);
@include stbui-theme($theme);
2 changes: 1 addition & 1 deletion src/app/component/date-picker/date-picker.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin date-picker-theme($theme) {
@mixin stbui-date-picker-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
Expand Down
2 changes: 1 addition & 1 deletion src/app/component/dialog/dialog.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin dialog-theme($theme) {
@mixin stbui-dialog-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
Expand Down
1 change: 0 additions & 1 deletion src/app/component/loading/loading.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
height: 96px;
line-height: 96px;
margin: 10px auto;
background: #3F51B5;
text-align: center;
border-radius: 2px;
box-shadow: 0 2px 14px 0 rgba(0, 0, 0, .22)
Expand Down
21 changes: 21 additions & 0 deletions src/app/component/loading/loading.theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@mixin stbui-loading-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);

.logo {
background-color: mat-color($primary);

&.mat-primary {
background-color: mat-color($primary);
}
&.mat-accent {
background-color: mat-color($accent);
}
&.mat-warn {
background-color: mat-color($warn);
}
}
}
2 changes: 1 addition & 1 deletion src/app/component/message/message.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin message-theme($theme) {
@mixin stbui-message-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
Expand Down
9 changes: 2 additions & 7 deletions src/app/component/notification/notification.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<mat-card class="notification"
[class.notification-success]="data.type==='success'"
[class.notification-info]="data.type==='info'"
[class.notification-warn]="data.type==='warn'"
[class.notification-error]="data.type==='error'"
>
<mat-card class="notification" [class.mat-accent]="data.type==='success'" [class.mat-primary]="data.type==='info'" [class.mat-warn]="data.type==='warn'">
<mat-card-subtitle class="notification-title">
{{data.title}}
<span style="flex: 1 1 1e-09px;"></span>
Expand All @@ -12,4 +7,4 @@
</button>
</mat-card-subtitle>
<mat-card-content class="notification-content" [innerHTML]="data.message"></mat-card-content>
</mat-card>
</mat-card>
24 changes: 11 additions & 13 deletions src/app/component/notification/notification.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin notification-theme($theme) {
@mixin stbui-notification-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
Expand All @@ -7,17 +7,15 @@

.notification {
background-color: mat-color($primary);
}
.notification-info {
background-color: mat-color($primary);
}
.notification-primary {
background-color: mat-color($primary);
}
.notification-success {
background-color: mat-color($accent);
}
.notification-warn {
background-color: mat-color($warn);

&.mat-primary {
background-color: mat-color($primary);
}
&.mat-accent {
background-color: mat-color($accent);
}
&.mat-warn {
background-color: mat-color($warn);
}
}
}
2 changes: 1 addition & 1 deletion src/app/component/notification/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export * from './notification-container';
export * from './notification.component';
export * from './notification.config';
export * from './notification.ref';
export * from './notification.animation';
export * from './notification.animation';
2 changes: 1 addition & 1 deletion src/app/component/pagination/pagination.theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin pagination-theme($theme) {
@mixin stbui-pagination-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
Expand Down
10 changes: 0 additions & 10 deletions src/app/component/tag-select/tag-select.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,3 @@
}
}
}

// theme
.tag-select {
&-item {
> a.active {
background-color: #3f51b5;
color: white;
}
}
}
18 changes: 13 additions & 5 deletions src/app/component/tag-select/tag-select.theme.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
.tag-select {
&-item {
> a.active {
background-color: #3f51b5;
color: white;
@mixin stbui-tag-select-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);

.tag-select {
&-item {
> a.active {
background-color: mat-color($primary);
color: #fff;
}
}
}
}
Loading

0 comments on commit 62801fa

Please sign in to comment.