From 3109960618339fbea488b36ad770513f61227c36 Mon Sep 17 00:00:00 2001 From: Uraz Akgultan Date: Sun, 22 Jan 2023 23:02:00 +0100 Subject: [PATCH] feat: add accessibility --- .../accordion-native/src/Accordion.xml | 2 +- .../src/BottomSheet.editorConfig.ts | 18 +++- .../bottom-sheet-native/src/BottomSheet.tsx | 3 + .../bottom-sheet-native/src/BottomSheet.xml | 41 +++++++- .../src/components/CustomModalSheet.tsx | 9 +- .../src/components/ExpandingDrawer.tsx | 12 ++- .../src/components/NativeBottomSheet.tsx | 11 ++- .../typings/BottomSheetProps.d.ts | 18 +++- .../src/Carousel.editorConfig.ts | 10 ++ .../carousel-native/src/Carousel.tsx | 3 + .../carousel-native/src/Carousel.xml | 54 +++++++---- .../typings/CarouselProps.d.ts | 10 +- .../src/ColorPicker.editorConfig.ts | 26 +++++ .../color-picker-native/src/ColorPicker.tsx | 36 ++++++- .../color-picker-native/src/ColorPicker.xml | 45 +++++++-- .../src/components/PickerSlider.tsx | 96 ++++++++++++++----- .../typings/ColorPickerProps.d.ts | 18 +++- .../src/Feedback.editorConfig.ts | 24 +++++ .../feedback-native/src/Feedback.tsx | 7 +- .../feedback-native/src/Feedback.xml | 21 +++- .../typings/FeedbackProps.d.ts | 8 ++ 21 files changed, 404 insertions(+), 68 deletions(-) create mode 100644 packages/pluggableWidgets/feedback-native/src/Feedback.editorConfig.ts diff --git a/packages/pluggableWidgets/accordion-native/src/Accordion.xml b/packages/pluggableWidgets/accordion-native/src/Accordion.xml index 5b49755f9..65c510cc5 100644 --- a/packages/pluggableWidgets/accordion-native/src/Accordion.xml +++ b/packages/pluggableWidgets/accordion-native/src/Accordion.xml @@ -67,7 +67,7 @@ - + Accessible diff --git a/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.editorConfig.ts b/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.editorConfig.ts index e176a2dcd..01136e9ba 100644 --- a/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.editorConfig.ts +++ b/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.editorConfig.ts @@ -87,9 +87,10 @@ export function getPreview(values: BottomSheetPreviewProps, isDarkMode: boolean) }; } -export function getProperties(values: any, defaultProperties: Properties): Properties { +export function getProperties(values: BottomSheetPreviewProps, defaultProperties: Properties): Properties { if (values.type === "modal") { if (values.modalRendering === "basic") { + hidePropertyIn(defaultProperties, values, "accessible"); hidePropertiesIn(defaultProperties, values, ["smallContent", "largeContent", "fullscreenContent"]); } else { hidePropertiesIn(defaultProperties, values, [ @@ -112,10 +113,23 @@ export function getProperties(values: any, defaultProperties: Properties): Prope hidePropertyIn(defaultProperties, values, "fullscreenContent"); } } + + if (values.accessible === "no" || (values.type === "modal" && values.modalRendering === "basic")) { + hidePropertyIn(defaultProperties, values, "screenReaderCaption"); + hidePropertyIn(defaultProperties, values, "screenReaderHint"); + } + + values.itemsBasic.forEach((item, index) => { + if (item.modalAccessible === "no") { + hidePropertyIn(defaultProperties, values, "itemsBasic", index, "modalScreenReaderCaption"); + hidePropertyIn(defaultProperties, values, "itemsBasic", index, "modalScreenReaderHint"); + } + }); + return defaultProperties; } -export function check(values: any): Problem[] { +export function check(values: BottomSheetPreviewProps): Problem[] { const errors: Problem[] = []; if (values.type === "modal") { if (!values.triggerAttribute) { diff --git a/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.tsx b/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.tsx index b0e936624..661f49687 100644 --- a/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.tsx +++ b/packages/pluggableWidgets/bottom-sheet-native/src/BottomSheet.tsx @@ -29,6 +29,9 @@ export function BottomSheet(props: BottomSheetProps): ReactEle if (props.type === "expanding") { return ( Trigger attribute Defines if the modal bottom sheet is visible or not. Initially this value should be false. When set to true, the bottom sheet will be shown. When the bottom sheet is hidden, the trigger attribute value is set to false. - + @@ -55,6 +55,25 @@ Custom + + Accessible + General + + + Yes + No + + + + Screen reader caption + General + + + + Screen reader hint + General + + @@ -87,9 +106,27 @@ - + + + + Accessible + + + Yes + No + + + + Screen reader caption + + + + Screen reader hint + + + diff --git a/packages/pluggableWidgets/bottom-sheet-native/src/components/CustomModalSheet.tsx b/packages/pluggableWidgets/bottom-sheet-native/src/components/CustomModalSheet.tsx index 042fb451c..1de56d3a6 100644 --- a/packages/pluggableWidgets/bottom-sheet-native/src/components/CustomModalSheet.tsx +++ b/packages/pluggableWidgets/bottom-sheet-native/src/components/CustomModalSheet.tsx @@ -1,13 +1,16 @@ import { createElement, ReactElement, ReactNode, useCallback, useEffect, useState } from "react"; import { InteractionManager, LayoutChangeEvent, SafeAreaView, StyleSheet, View } from "react-native"; import Modal, { OnSwipeCompleteParams } from "react-native-modal"; -import { EditableValue, ValueStatus } from "mendix"; +import { DynamicValue, EditableValue, ValueStatus } from "mendix"; import { BottomSheetStyle, defaultPaddings } from "../ui/Styles"; interface CustomModalSheetProps { triggerAttribute?: EditableValue; content?: ReactNode; styles: BottomSheetStyle; + accessible?: boolean; + screenReaderCaption?: DynamicValue; + screenReaderHint?: DynamicValue; } export const CustomModalSheet = (props: CustomModalSheetProps): ReactElement => { @@ -62,6 +65,10 @@ export const CustomModalSheet = (props: CustomModalSheetProps): ReactElement => return ( 0 }} isVisible={currentStatus} coverScreen backdropOpacity={0.5} diff --git a/packages/pluggableWidgets/bottom-sheet-native/src/components/ExpandingDrawer.tsx b/packages/pluggableWidgets/bottom-sheet-native/src/components/ExpandingDrawer.tsx index 4e48c161a..6e396a136 100644 --- a/packages/pluggableWidgets/bottom-sheet-native/src/components/ExpandingDrawer.tsx +++ b/packages/pluggableWidgets/bottom-sheet-native/src/components/ExpandingDrawer.tsx @@ -1,7 +1,8 @@ -import { BottomSheetStyle } from "../ui/Styles"; import { createElement, ReactNode, useCallback, useState, ReactElement, Children } from "react"; -import BottomSheet from "reanimated-bottom-sheet"; import { Dimensions, LayoutChangeEvent, SafeAreaView, StyleSheet, View } from "react-native"; +import BottomSheet from "reanimated-bottom-sheet"; +import { DynamicValue } from "mendix"; +import { BottomSheetStyle } from "../ui/Styles"; interface ExpandingDrawerProps { smallContent?: ReactNode; @@ -10,6 +11,9 @@ interface ExpandingDrawerProps { onOpen?: () => void; onClose?: () => void; styles: BottomSheetStyle; + accessible?: boolean; + screenReaderCaption?: DynamicValue; + screenReaderHint?: DynamicValue; } export const ExpandingDrawer = (props: ExpandingDrawerProps): ReactElement => { @@ -56,6 +60,10 @@ export const ExpandingDrawer = (props: ExpandingDrawerProps): ReactElement => { pointerEvents="box-none" > ( - + {item.caption} )); diff --git a/packages/pluggableWidgets/bottom-sheet-native/typings/BottomSheetProps.d.ts b/packages/pluggableWidgets/bottom-sheet-native/typings/BottomSheetProps.d.ts index ef9f09b5d..6445576bd 100644 --- a/packages/pluggableWidgets/bottom-sheet-native/typings/BottomSheetProps.d.ts +++ b/packages/pluggableWidgets/bottom-sheet-native/typings/BottomSheetProps.d.ts @@ -4,7 +4,7 @@ * @author Mendix UI Content Team */ import { ComponentType, CSSProperties, ReactNode } from "react"; -import { ActionValue, EditableValue } from "mendix"; +import { ActionValue, DynamicValue, EditableValue } from "mendix"; export type TypeEnum = "modal" | "expanding"; @@ -12,16 +12,26 @@ export type ModalRenderingEnum = "basic" | "custom"; export type StyleClassEnum = "defaultStyle" | "primaryStyle" | "dangerStyle" | "customStyle"; +export type ModalAccessibleEnum = "yes" | "no"; + export interface ItemsBasicType { caption: string; action?: ActionValue; styleClass: StyleClassEnum; + modalAccessible: ModalAccessibleEnum; + modalScreenReaderCaption?: DynamicValue; + modalScreenReaderHint?: DynamicValue; } +export type AccessibleEnum = "yes" | "no"; + export interface ItemsBasicPreviewType { caption: string; action: {} | null; styleClass: StyleClassEnum; + modalAccessible: ModalAccessibleEnum; + modalScreenReaderCaption: string; + modalScreenReaderHint: string; } export interface BottomSheetProps