This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terra-toggle]fixing focus issue & added expanded & collapse state (#…
…3715) * first commit * updated Example * lint changes * Tab Focus * focus styles * minor changes --------- Co-authored-by: Supreeth <supreeth.mr1990@gmail.com>
- Loading branch information
1 parent
151b2c6
commit facc56b
Showing
6 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/terra-core-docs/src/terra-dev-site/doc/toggle/example/ToggleExample.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:local { | ||
[data-show-focus-styles='false']:focus { | ||
outline: none; | ||
} | ||
|
||
[data-show-focus-styles='true']:focus { | ||
outline: 2px dashed #000; | ||
outline-offset: 2px; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/terra-core-docs/src/terra-dev-site/doc/toggle/example/ToggleWithLabel.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useState } from 'react'; | ||
import Toggle from 'terra-toggle'; | ||
import IconInformation from 'terra-icon/lib/icon/IconInformation'; | ||
import { KEY_TAB } from 'keycode-js'; | ||
import './ToggleExample.module.scss'; | ||
|
||
const ToggleWithLabel = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [focused, setFocus] = useState(true); | ||
const handleOnClick = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
const handleOnKeyDown = (event) => { | ||
if (event.nativeEvent.keyCode === KEY_TAB) { | ||
setFocus(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<label htmlFor="Icon-label"> | ||
<IconInformation data-show-focus-styles={focused} focusable onKeyDown={handleOnKeyDown} onMouseDown={() => { setFocus(false); }} onClick={handleOnClick} a11yLabel="information Icon" tabIndex="0" role="button" aria-expanded={isOpen} aria-controls="toggle" id="Icon-label" /> | ||
<span id="Icon-label"> Toggle label</span> | ||
</label> | ||
<Toggle isOpen={isOpen} isAnimated> | ||
<p> | ||
Cerner provides research solutions and services to support clinical sites and academic institutions. | ||
<a href="https://www.cerner.com/gb/en/solutions/data-research">Data and research</a> | ||
{' '} | ||
We bring a deep understanding of clinical systems, workflows and health data, as well as extensive experience in pharmaceutical, outcomes and health economic research. Through medical and economic analyses, researchers gain insights into the viability, safety, and efficacy of new and existing therapies. Principal investigators and research coordinators can use the Cerner EHR to facilitate and enhance their research activities. | ||
</p> | ||
</Toggle> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ToggleWithLabel; |