Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
c562f2b4
Commit
c562f2b4
authored
Jul 28, 2020
by
Kyle Keating
Committed by
Kyle Keating
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve button types
parent
41f289d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
40 deletions
+28
-40
button.js
src/sidebar/components/button.js
+28
-40
No files found.
src/sidebar/components/button.js
View file @
c562f2b4
...
@@ -3,12 +3,39 @@ import propTypes from 'prop-types';
...
@@ -3,12 +3,39 @@ import propTypes from 'prop-types';
import
SvgIcon
from
'../../shared/components/svg-icon'
;
import
SvgIcon
from
'../../shared/components/svg-icon'
;
/**
* @typedef ButtonProps
* @prop {string} [buttonText] -
* The presence of this property indicates that the button will have a visibly-rendered
* label (with this prop's value). For brevity, when providing `buttonText`, the `title`
* prop is optional—if `title` is not present, the value of `buttonText` will be used for
* the button's `title` attribute, as they are typically identical. When this prop is
* missing, an icon-only button will be rendered.
* @prop {string} [className] -
* When present, this will be used as the base class name and will override all styling.
* See `buttons` SCSS mixins module for more details.
* @prop {string} [icon] -
* The name of the SVGIcon to render. This is optional if a `buttonText` is provided.
* @prop {boolean} [isExpanded] -
* Is the expandable element controlled by this button currently expanded?
* @prop {boolean} [isPressed] -
* Indicate that this is a toggle button (if `isPressed` is a boolean) and whether it
* is pressed. If omitted, the button is a non-toggle button.
* @prop {(e: Event) => any} onClick - callback for button clicks
* @prop {boolean} [disabled] - disables the button when true
* @prop {Object} [style] - optional inline styling
* @prop {string} [title] -
* `title`, used for button `title`, is required unless `buttonText` is present
*/
/**
/**
* A button.
* A button.
*
*
* By default, styling will be applied for the button based on its general
* By default, styling will be applied for the button based on its general
* "type" (e.g. an icon-only button, a labeled button). The presence of a
* "type" (e.g. an icon-only button, a labeled button). The presence of a
* `className` prop will disable all default styling.
* `className` prop will disable all default styling.
*
* @param {ButtonProps} props
*/
*/
export
default
function
Button
({
export
default
function
Button
({
buttonText
=
''
,
buttonText
=
''
,
...
@@ -80,52 +107,13 @@ if string property 'buttonText' omitted`
...
@@ -80,52 +107,13 @@ if string property 'buttonText' omitted`
}
}
Button
.
propTypes
=
{
Button
.
propTypes
=
{
/**
* The presence of this property indicates that the button will have a
* visibly-rendered label (with this prop's value). For brevity, when providing
* `buttonText`, the `title` prop is optional—if `title` is not present,
* the value of `buttonText` will be used for the button's `title` attribute,
* as they are typically identical. When this prop is missing, an icon-only
* button will be rendered.
*/
buttonText
:
propTypes
.
string
,
buttonText
:
propTypes
.
string
,
/**
* When present, this will be used as the base class name and will override
* all styling. See `buttons` SCSS mixins module for more details.
*/
className
:
propTypes
.
string
,
className
:
propTypes
.
string
,
/**
* The name of the SVGIcon to render. This is optional if a `buttonText` is
* provided.
*/
icon
:
requiredStringIfButtonTextMissing
,
icon
:
requiredStringIfButtonTextMissing
,
/**
* Is the expandable element controlled by this button currently expanded?
*/
isExpanded
:
propTypes
.
bool
,
isExpanded
:
propTypes
.
bool
,
/**
* Indicate that this is a toggle button (if `isPressed` is a boolean) and
* whether it is pressed.
*
* If omitted, the button is a non-toggle button.
*/
isPressed
:
propTypes
.
bool
,
isPressed
:
propTypes
.
bool
,
onClick
:
propTypes
.
func
.
isRequired
,
/** callback for button clicks */
onClick
:
propTypes
.
func
,
/** disables the button when true */
disabled
:
propTypes
.
bool
,
disabled
:
propTypes
.
bool
,
/** optional inline styling */
style
:
propTypes
.
object
,
style
:
propTypes
.
object
,
/**
* `title`, used for button `title`, is required unless `buttonText` is present
*/
title
:
requiredStringIfButtonTextMissing
,
title
:
requiredStringIfButtonTextMissing
,
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment