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

feat(MdCheckbox): add indeterminate look, prop #1597

Merged
merged 4 commits into from
Mar 27, 2018
Merged
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
6 changes: 6 additions & 0 deletions docs/app/pages/Components/Checkbox/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
type: 'String',
description: 'The checkbox unique id.',
defaults: 'a random string'
},
{
name: 'indeterminate',
type: 'Boolean',
description: 'Enables the indeterminate look of the checkbox.',
defaults: 'false'
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<md-checkbox v-model="obj" :value="obj1">Object 1</md-checkbox>
<md-checkbox v-model="obj" :value="obj2">Object 2</md-checkbox>

<md-checkbox v-model="indeterminate" indeterminate>Indeterminate</md-checkbox>

<table>
<tr>
<th>Array</th>
Expand Down Expand Up @@ -40,7 +42,8 @@
disabled: true,
obj1: {name: 'obj1'},
obj2: {name: 'obj2'},
obj: null
obj: null,
indeterminate: true
})
}
</script>
Expand Down
18 changes: 17 additions & 1 deletion src/components/MdCheckbox/MdCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="md-checkbox" :class="[$mdActiveTheme, checkClasses]">
<div class="md-checkbox-container" @click.stop="toggleCheck">
<md-ripple md-centered :md-active.sync="rippleActive" :md-disabled="disabled">
<input type="checkbox" v-bind="{ id, name, disabled, required, value }">
<input type="checkbox" v-bind="{ id, name, disabled, required, value }" :indeterminate.prop="indeterminate">
</md-ripple>
</div>

Expand Down Expand Up @@ -115,6 +115,22 @@
}
}

.md-checkbox.md-indeterminate {
.md-checkbox-container {
&:after {
width: 12px;
height: 2px;
top: 50%;
left: 50%;
z-index: 7;
border-style: solid;
border-width: 0 0 2px;
opacity: 0;
transform: translate(-50%, -50%) !important;
}
}
}

.md-checkbox.md-checked {
.md-checkbox-container {
&:after {
Expand Down
6 changes: 4 additions & 2 deletions src/components/MdCheckbox/MdCheckboxMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default {
},
name: [String, Number],
required: Boolean,
disabled: Boolean
disabled: Boolean,
indeterminate: Boolean
},
model: {
prop: 'model',
Expand Down Expand Up @@ -43,7 +44,8 @@ export default {
return {
'md-checked': this.isSelected,
'md-disabled': this.disabled,
'md-required': this.required
'md-required': this.required,
'md-indeterminate': this.indeterminate
}
}
},
Expand Down
38 changes: 38 additions & 0 deletions src/components/MdCheckbox/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
}
}

&.md-indeterminate {
.md-checkbox-container {
border-color: rgba(#000, .54);
background-color: rgba(#fff, .3);
&:after {
border-color: rgba(#000, .54);
}
}
.md-ripple {
color: rgba(#000, .54);
}
}

&.md-checked.md-primary {
.md-checkbox-container {
@include md-theme-property(background-color, primary);
Expand All @@ -27,6 +40,18 @@
}

@if md-get-theme-mode() == light {
&.md-indeterminate {
.md-checkbox-container {
border-color: rgba(#000, .54);
background-color: transparent;
&:after {
border-color: rgba(#000, .54);
}
}
.md-ripple {
color: rgba(#000, .54);
}
}
.md-checkbox-container {
border-color: rgba(#000, .54);
}
Expand All @@ -44,6 +69,19 @@
}
}
} @else {
&.md-indeterminate {
.md-checkbox-container {
border-color: rgba(#fff, .7);
background-color: transparent;
&:after {
border-color: rgba(#fff, .7);
}
}
.md-ripple {
color: rgba(#fff, .7);
}
}

.md-checkbox-container {
border-color: rgba(#fff, .7);
}
Expand Down