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

Added dojo theme #77

Merged
merged 8 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ module.exports = function (grunt) {
devStyles: {
expand: true,
cwd: 'src',
src: 'common/styles/widgets.css',
src: '**/widgets.css',
dest: '<%= devDirectory %>'
},
distStyles: {
expand: true,
cwd: 'src',
src: 'common/styles/widgets.css',
src: '**/widgets.css',
dest: '<%= distDirectory %>'
}
},
Expand Down
13 changes: 6 additions & 7 deletions src/button/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,18 @@ export default class Button extends ButtonBase<ButtonProperties> {
value
} = this.properties;

const stateClasses = [
disabled ? css.disabled : null,
popup ? css.popup : null,
pressed ? css.pressed : null
];

if (popup === true) {
popup = { expanded: false, id: '' };
}

return v('button', {
innerHTML: content,
classes: this.classes(css.button, ...stateClasses),
classes: this.classes(
css.root,
disabled ? css.disabled : null,
popup ? css.popup : null,
pressed ? css.pressed : null
),
'aria-describedby': describedBy,
disabled,
'aria-haspopup': popup ? 'true' : null,
Expand Down
19 changes: 19 additions & 0 deletions src/button/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import { StatefulMixin } from '@dojo/widget-core/mixins/Stateful';
import { ProjectorMixin } from '@dojo/widget-core/mixins/Projector';
import { w, v } from '@dojo/widget-core/d';
import Button, { ButtonType } from '../../button/Button';
import dojoTheme from '../../themes/dojo/theme';

export const AppBase = StatefulMixin(WidgetBase);
export class App extends AppBase<WidgetProperties> {
private _theme: {};

themeChange(event: Event) {
const checked = (<HTMLInputElement> event.target).checked;
this._theme = checked ? dojoTheme : {};
this.invalidate();
}

toggleButton() {
this.setState({ buttonPressed: !this.state.buttonPressed });
}
Expand All @@ -16,18 +25,27 @@ export class App extends AppBase<WidgetProperties> {
v('h2', {
innerHTML: 'Button Examples'
}),
v('label', [
'Use Dojo Theme ',
v('input', {
type: 'checkbox',
onchange: this.themeChange
})
]),
v('p', {
innerHTML: 'Basic example:'
}),
w(Button, {
key: 'b1',
theme: this._theme,
content: 'Basic Button'
}),
v('p', {
innerHTML: 'Disabled menu button:'
}),
w(Button, {
key: 'b2',
theme: this._theme,
content: 'Open',
disabled: true,
popup: { expanded: false, id: 'fakeId' },
Expand All @@ -38,6 +56,7 @@ export class App extends AppBase<WidgetProperties> {
}),
w(Button, {
key: 'b4',
theme: this._theme,
content: 'Button state',
pressed: <boolean> this.state.buttonPressed,
onClick: this.toggleButton
Expand Down
27 changes: 7 additions & 20 deletions src/button/styles/button.m.css
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
@import '../../common/styles/variables.css';

.button {
background-color: var(--button-bg);
border: 1px solid var(--button-bg);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
border-radius: var(--rounded-corners);
color: var(--button-color);
.root {
cursor: pointer;
font: var(--base-font);
font-weight: bold;
display: inline-block;
padding: var(--button-padding);
transition: all var(--short-animation-duration) ease;
}

.button:hover,
.button:focus {
background-color: var(--button-hover-bg);
border-color: var(--button-hover-bg);
.root:hover,
.root:focus {
outline: none;
}

.pressed::before {
border-bottom: 2px solid var(--button-color);
border-right: 2px solid var(--button-color);
border-bottom: 2px solid black;
border-right: 2px solid black;
box-sizing: border-box;
content: '';
display: inline-block;
Expand All @@ -34,8 +23,8 @@
}

.popup::after {
border-bottom: 2px solid var(--button-color);
border-right: 2px solid var(--button-color);
border-bottom: 2px solid black;
border-right: 2px solid black;
box-sizing: border-box;
content: '';
display: inline-block;
Expand All @@ -47,7 +36,5 @@

.disabled,
.disabled:hover {
background-color: var(--button-disabled-bg);
border-color: var(--button-disabled-bg);
cursor: default;
}
2 changes: 1 addition & 1 deletion src/button/styles/button.m.css.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const button: string;
export const root: string;
export const pressed: string;
export const popup: string;
export const disabled: string;
121 changes: 69 additions & 52 deletions src/checkbox/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import { ProjectorMixin } from '@dojo/widget-core/mixins/Projector';
import { StatefulMixin } from '@dojo/widget-core/mixins/Stateful';
import { v, w } from '@dojo/widget-core/d';
import Checkbox, { Mode } from '../../checkbox/Checkbox';
import dojoTheme from '../../themes/dojo/theme';

export const AppBase = StatefulMixin(WidgetBase);
export class App extends AppBase<WidgetProperties> {
private _theme: {};

themeChange(event: Event) {
const checked = (<HTMLInputElement> event.target).checked;
this._theme = checked ? dojoTheme : {};
this.invalidate();
}

onChange(event: Event) {
const value = (<HTMLInputElement> event.target).value;
const checked = (<HTMLInputElement> event.target).checked;
Expand All @@ -22,59 +31,67 @@ export class App extends AppBase<WidgetProperties> {
c5 = true
} = this.state;

return v('fieldset', [
v('legend', {}, ['Checkbox Example']),
w(Checkbox, {
key: 'c1',
checked: <boolean> c1,
label: {
content: 'Sample checkbox that starts checked',
before: false
},
value: 'c1',
onChange: this.onChange
}),
w(Checkbox, {
key: 'c2',
checked: <boolean> c2,
label: {
content: 'Sample disabled checkbox',
before: false
},
disabled: true,
value: 'c2',
onChange: this.onChange
}),
w(Checkbox, {
key: 'c3',
checked: <boolean> c3,
label: {
content: 'Required checkbox',
before: false
},
required: true,
value: 'c3',
onChange: this.onChange
}),
w(Checkbox, {
key: 'c4',
checked: <boolean> c4,
label: 'Checkbox in "toggle" mode',
mode: Mode.toggle,
value: 'c4',
onChange: this.onChange
return v('div', [
v('h2', {
innerHTML: 'Checkbox Examples'
}),
w(Checkbox, {
key: 'c5',
checked: <boolean> c5,
label: 'Disabled toggle mode',
onLabel: 'On',
offLabel: 'Off',
mode: Mode.toggle,
disabled: true,
value: 'c5',
onChange: this.onChange
})
v('label', [
'Use Dojo Theme ',
v('input', {
type: 'checkbox',
onchange: this.themeChange
})
]),
v('fieldset', [
v('legend', {}, ['Checkbox Example']),
w(Checkbox, {
key: 'c1',
checked: <boolean> c1,
label: 'Sample checkbox that starts checked',
value: 'c1',
onChange: this.onChange,
theme: this._theme
}),
w(Checkbox, {
key: 'c2',
checked: <boolean> c2,
label: 'Sample disabled checkbox',
disabled: true,
value: 'c2',
onChange: this.onChange,
theme: this._theme
}),
w(Checkbox, {
key: 'c3',
checked: <boolean> c3,
label: 'Required checkbox',
required: true,
value: 'c3',
onChange: this.onChange,
theme: this._theme
}),
w(Checkbox, {
key: 'c4',
checked: <boolean> c4,
label: 'Checkbox in "toggle" mode',
mode: Mode.toggle,
value: 'c4',
onChange: this.onChange,
theme: this._theme
}),
w(Checkbox, {
key: 'c5',
checked: <boolean> c5,
label: 'Disabled toggle mode',
onLabel: 'On',
offLabel: 'Off',
mode: Mode.toggle,
disabled: true,
value: 'c5',
onChange: this.onChange,
theme: this._theme
})
])
]);
}
}
Expand Down
Loading