-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #727 from woowacourse-teams/refactor/722-tag-regis…
…tration-announcement [접근성개선] 스크린 리더가 태그 등록 메시지 안내
- Loading branch information
Showing
6 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
frontend/src/components/ScreenReaderOnly/ScreenReaderOnly.tsx
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,21 @@ | ||
const ScreenReaderOnly = () => ( | ||
<div | ||
id='screen-reader' | ||
aria-live='polite' | ||
aria-hidden='true' | ||
style={{ | ||
position: 'absolute', | ||
width: '1px', | ||
height: '1px', | ||
margin: '-1px', | ||
padding: '0', | ||
border: '0', | ||
overflow: 'hidden', | ||
clip: 'rect(0, 0, 0, 0)', | ||
whiteSpace: 'nowrap', | ||
wordWrap: 'normal', | ||
}} | ||
/> | ||
); | ||
|
||
export default ScreenReaderOnly; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useCallback } from 'react'; | ||
|
||
export const useScreenReader = () => { | ||
const updateScreenReaderMessage = useCallback((message: string) => { | ||
const element = document.getElementById('screen-reader'); | ||
|
||
if (element) { | ||
element.setAttribute('aria-hidden', 'false'); | ||
element.textContent = message; | ||
|
||
setTimeout(() => { | ||
element.setAttribute('aria-hidden', 'true'); | ||
element.textContent = ''; | ||
}); | ||
} | ||
}, []); | ||
|
||
return { updateScreenReaderMessage }; | ||
}; |
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