-
-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(a11y): whatwg-compliant accessibility for images
Images now hold the `accessibilityRole` and `accessibilityLabel` regardless of the internal state (loading, success, error). Also note that an image with `alt=""` or no `alt` attribute will not be accessible, as mandated by WHATWG HTML standard.
- Loading branch information
Showing
10 changed files
with
99 additions
and
64 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
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
22 changes: 22 additions & 0 deletions
22
packages/render-html/src/helpers/getNativePropsForTNode.ts
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,22 @@ | ||
import { TBlock, TPhrasing, TText } from '@native-html/transient-render-engine'; | ||
import { TDefaultRendererProps } from '../shared-types'; | ||
|
||
/** | ||
* Extract React Native props for a given {@link TNode}. Native props target | ||
* either `Text` or `View` elements, with an optional `onPress` prop for | ||
* interactive elements. | ||
*/ | ||
export default function getNativePropsForTNode( | ||
props: TDefaultRendererProps<TPhrasing | TText | TBlock> | ||
) { | ||
const { tnode, style, type, nativeProps, onPress } = props; | ||
const switchProp = type === 'block' ? props.viewProps : props.textProps; | ||
return { | ||
...tnode.getReactNativeProps()?.[type === 'block' ? 'view' : 'text'], | ||
...nativeProps, | ||
...switchProp, | ||
onPress, | ||
style: [style, nativeProps?.style, switchProp.style], | ||
testID: tnode.tagName || undefined | ||
}; | ||
} |
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