Skip to content

Commit

Permalink
fix(vote): add weak to thytype (#474)
Browse files Browse the repository at this point in the history
* fix(vote): support weak

* fix(button-icon): support color

* fix(vote): add weak to thytype

Co-authored-by: Walker <15701592+walkerkay@users.noreply.github.com>
  • Loading branch information
2 people authored and why520crazy committed Dec 27, 2019
1 parent 4565c8b commit 2ceb18e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
8 changes: 1 addition & 7 deletions demo/src/app/components/+vote/vote.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class DemoVoteComponent {
public apiParameters = [
{
property: 'thyVote',
description: '标签类型(primary、success)',
description: '标签类型(primary、success、primary-weak、success-weak)',
type: 'ThyVote',
default: 'primary'
},
Expand Down Expand Up @@ -39,12 +39,6 @@ export class DemoVoteComponent {
description: '赞同的数量',
type: 'number | string',
default: ''
},
{
property: 'thyWeak',
description: '是否是弱化样式',
type: 'string | boolean',
default: 'false'
}
];
liveDemos: LiveDemoCodeExample[] = [
Expand Down
3 changes: 1 addition & 2 deletions demo/src/app/components/+vote/weak/vote-weak.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<span
class="mt-3"
[thyVote]="'success'"
[thyVote]="'success-weak'"
[thyLayout]="'vertical'"
[thyVoteCount]="vote_count"
[thyHasVoted]="has_voted"
thySize="md"
(click)="toggleVote($event)"
thyWeak="true"
></span>
12 changes: 8 additions & 4 deletions src/vote/styles/vote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
background: rgba($color, 0.15);
color: $color;
&:hover {
background: rgba($color, 0.3) !important;
color: $color !important;
background: rgba($color, 0.2);
color: $color;
}
&.has-voted {
background: $color;
Expand All @@ -14,12 +14,16 @@
background-color: $gray-100;
color: $gray-600;
&:hover {
background: $color !important;
color: $white !important;
background: $color;
color: $white;
}
&.has-voted {
background: rgba($color, 0.1);
color: $color;
&:hover {
background: $color;
color: $white;
}
}
}
@mixin vote-variant($height, $padding, $fontSize, $iconSize) {
Expand Down
18 changes: 2 additions & 16 deletions src/vote/vote.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UpdateHostClassService } from '../shared';

export type ThySizes = 'sm' | 'md';

export type ThyType = 'primary' | 'success';
export type ThyType = 'primary' | 'success' | 'primary-weak' | 'success-weak';

export type thyLayout = 'vertical' | 'horizontal';

Expand All @@ -20,8 +20,6 @@ export class ThyVoteComponent implements OnInit {

_layout: thyLayout;

_isWeak = false;

_initialized = false;

@HostBinding(`class.thy-vote`) class = true;
Expand Down Expand Up @@ -52,14 +50,6 @@ export class ThyVoteComponent implements OnInit {
}
}

@Input()
set thyWeak(value: string | boolean) {
this._isWeak = inputValueToBoolean(value);
if (this._initialized) {
this._setClassesByType();
}
}

@Input() thyVoteCount: number | string;

@Input()
Expand Down Expand Up @@ -90,11 +80,7 @@ export class ThyVoteComponent implements OnInit {
if (!this._size) {
this._size = 'sm';
}
if (this._isWeak) {
className.push(`thy-vote-${this._type}-weak`);
} else {
className.push(`thy-vote-${this._type}`);
}
className.push(`thy-vote-${this._type}`);
className.push(`thy-vote-${this._layout}`);
className.push(`thy-vote-${this._layout}-size-${this._size}`);
this.updateHostClassService.updateClass(className);
Expand Down

0 comments on commit 2ceb18e

Please sign in to comment.