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

Support different kinds of button without variants #1751

Merged
merged 2 commits into from
May 28, 2021
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
2 changes: 0 additions & 2 deletions .dojorc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@
"src/chip-typeahead",
"src/native-select",
"src/number-input",
"src/outlined-button",
"src/pagination",
"src/password-input",
"src/popup",
"src/popup-confirmation",
"src/progress",
"src/radio",
"src/radio-group",
"src/raised-button",
"src/range-slider",
"src/rate",
"src/result",
Expand Down
98 changes: 55 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"prettier": "1.17.0",
"shx": "^0.2.2",
"sinon": "^4.1.3",
"typescript": "~3.4.5"
"typescript": "~3.5.3"
},
"dependencies": {
"tslib": "~1.9.1"
Expand Down
1 change: 1 addition & 0 deletions src/accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Set from '@dojo/framework/shim/Set';
import * as css from '../theme/default/accordion.m.css';
import * as titlePaneCss from '../theme/default/title-pane.m.css';
import TitlePane from '../title-pane';
Expand Down
3 changes: 1 addition & 2 deletions src/button/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @dojo/widgets/button

Dojo's `Button` widget creates a `<button>` element with support `pressed` and `disabled` states.
Dojo's `Button` widget creates a `<button>` element with support `disabled` states.

## Features

Expand All @@ -15,4 +15,3 @@ Icon only buttons will be sized to support a `24px` icon instead of the default
### Accessibility Features

- The basic button provides a strongly typed `type` property, as well as `disabled`
- Setting `pressed` to create a toggle button handles `aria-pressed`
14 changes: 5 additions & 9 deletions src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export interface ButtonProperties {
onOver?(): void;
/** Handler for events triggered by "on up" */
onUp?(): void;
/** Indicates status of a toggle button */
pressed?: boolean;
/** Button type can be "submit", "reset", "button", or "menu" */
type?: 'submit' | 'reset' | 'button' | 'menu';
/** Defines a value for the button submitted with form data */
Expand All @@ -38,7 +36,7 @@ export interface ButtonProperties {
/** The title text for the button node */
title?: string;
/** The kind of button */
kind?: 'primary' | 'secondary' | 'default';
kind?: 'contained' | 'outlined' | 'text';
/** Where to add the icon. Default to "before" */
iconPosition?: 'before' | 'after';
}
Expand All @@ -65,7 +63,6 @@ export const Button = factory(function Button({
disabled,
widgetId,
name,
pressed,
type = 'button',
value,
onClick,
Expand All @@ -76,7 +73,7 @@ export const Button = factory(function Button({
onBlur,
onFocus,
title,
kind = 'default',
kind = 'contained',
iconPosition = 'before'
} = properties();

Expand All @@ -96,9 +93,9 @@ export const Button = factory(function Button({
theme.variant(),
themeCss.root,
disabled ? themeCss.disabled : null,
pressed ? themeCss.pressed : null,
kind === 'secondary' ? themeCss.secondaryKind : null,
kind === 'default' ? themeCss.defaultKind : null,
kind === 'text' ? themeCss.text : null,
kind === 'contained' ? themeCss.contained : null,
kind === 'outlined' ? themeCss.outlined : null,
iconOnly ? themeCss.iconOnly : null
]}
title={title}
Expand All @@ -119,7 +116,6 @@ export const Button = factory(function Button({
onpointerdown={() => onDown && onDown()}
onpointerup={() => onUp && onUp()}
{...formatAriaProperties(aria)}
aria-pressed={typeof pressed === 'boolean' ? (pressed ? 'true' : 'false') : undefined}
>
{icon && iconPosition === 'before' ? iconSpan : undefined}
{label ? <span classes={themeCss.label}>{label}</span> : undefined}
Expand Down
Loading