Skip to content

Commit

Permalink
feat(selector-counter): Add .accessible-hide and also style the label…
Browse files Browse the repository at this point in the history
… on the last example

Since they lost some globally scoped styles
  • Loading branch information
lzcabrera committed Jan 18, 2018
1 parent 53073ce commit 2fbd048
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
8 changes: 8 additions & 0 deletions docs/scss/_examples.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@
display: flex;
height: 100%;
}

.docs_selcounter-label {
display: inline-block;
font-weight: 700;
color: $color-shark;
letter-spacing: -0.6px;
margin-bottom: 3px;
}
16 changes: 8 additions & 8 deletions src/old-components/SelectorCounter/SelectorCounter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SelectorCounter extends Component {
this.handleIncrement = this.handleIncrement.bind(this)
this.handleDecrement = this.handleDecrement.bind(this)
this.state = {
value: props.defaultValue
value: props.defaultValue,
}
}

Expand Down Expand Up @@ -71,14 +71,14 @@ class SelectorCounter extends Component {
invalid,
max,
min,
successful
successful,
} = this.props
const value = this.state.value

const cssClasses = {
'selector-counter--disabled': disabled,
'selector-counter--error': invalid,
'selector-counter--successful': successful
'selector-counter--successful': successful,
}
/* eslint-disable */
return (
Expand All @@ -87,7 +87,7 @@ class SelectorCounter extends Component {
{`${contextPrefix} ${value} ${contextSuffix}`}
</div>
<input
ref={input => this.input = input}
ref={input => (this.input = input)}
id={id}
type="number"
pattern="\d*"
Expand All @@ -112,11 +112,11 @@ class SelectorCounter extends Component {
label={decrementorLabel}
icon="caret-down"
onClick={this.handleDecrement}
disabled={(disabled === true || value <= min)}
disabled={disabled === true || value <= min}
aria-controls={id}
/>
</div>
);
)
/* eslint-enable */
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ SelectorCounter.propTypes = {
*
* Accessible text suffix for the change event announcement.
*/
contextSuffix: PropTypes.string
contextSuffix: PropTypes.string,
}

SelectorCounter.defaultProps = {
Expand All @@ -193,7 +193,7 @@ SelectorCounter.defaultProps = {
invalid: false,
successful: false,
contextPrefix: '',
contextSuffix: ''
contextSuffix: '',
}

export default SelectorCounter
2 changes: 1 addition & 1 deletion src/old-components/SelectorCounter/SelectorCounter.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const helperSuccess = successful? 'helper--success':'';
<form onSubmit={handleSubmit}>
<div className={`field ${fieldError} ${fieldSuccess}`}>
<label htmlFor="ex-selcounter">How many smartphone plans?</label>
<label htmlFor="ex-selcounter" className="docs_selcounter-label">How many smartphone plans?</label>
<div id="ex-selcounter-desc">
<Paragraph size="small">Instructions</Paragraph>
<UnorderedList listStyle={listType}>
Expand Down
15 changes: 15 additions & 0 deletions src/old-components/SelectorCounter/SelectorCounter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,18 @@ input.selector-counter__value.selector-counter__value {
width: 100%;
transition: background-color 0.1s linear;
}

.accessible-hide {
display: block;
position: absolute !important;
clip: rect(1px 1px 1px 1px);
clip: rect(1px, 1px, 1px, 1px);
left: -10000px;
top: auto;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
border: 0;
overflow: hidden;
}

0 comments on commit 2fbd048

Please sign in to comment.