Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testIDs prop to SegmentedControl #19

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@department-of-veterans-affairs/mobile-component-library",
"version": "0.0.18",
"version": "0.0.22",
"description": "VA Design System Mobile Component Library",
"main": "src/index.tsx",
"scripts": {
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"homepage": "https://department-of-veterans-affairs.github.io/va-mobile-library",
"dependencies": {
"@department-of-veterans-affairs/mobile-tokens": "0.0.7",
"@department-of-veterans-affairs/mobile-tokens": "0.0.10",
"@os-team/i18next-react-native-language-detector": "^1.0.28",
"i18next": "^23.4.3",
"react-i18next": "^13.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const twoSegments: Story = {
'You have 3 unread messages. Review messages in your inbox',
'Review your folders',
],
testIDs: ['test-id-1', 'test-id-2'],
},
parameters: {
design: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Colors } from '@department-of-veterans-affairs/mobile-tokens'
import * as DesignTokens from '@department-of-veterans-affairs/mobile-tokens'
import {
Text,
TextStyle,
Expand Down Expand Up @@ -27,6 +27,8 @@ export type SegmentedControlProps = {
a11yLabels?: string[]
/** Optional array of segment accessibility hints */
a11yHints?: string[]
/** Optional array of test IDs for test suites */
testIDs?: string[]
}

type SegmentProps = {
Expand All @@ -52,6 +54,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
selected,
a11yLabels,
a11yHints,
testIDs,
}) => {
const { t } = useTranslation()
const colorScheme = useColorScheme()
Expand All @@ -63,13 +66,13 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
let textColor: string, activeBgColor: string, inactiveBgColor: string

if (colorScheme === 'light') {
textColor = Colors.grayDark
activeBgColor = Colors.white
inactiveBgColor = Colors.grayLighter
textColor = DesignTokens.colorGrayDark
activeBgColor = DesignTokens.colorWhite
inactiveBgColor = DesignTokens.colorGrayLighter
} else {
textColor = Colors.grayLightest
activeBgColor = Colors.grayMedium
inactiveBgColor = Colors.grayDark
textColor = DesignTokens.colorGrayLightest
activeBgColor = DesignTokens.colorGrayMedium
inactiveBgColor = DesignTokens.colorGrayDark
}

const viewStyle: ViewStyle = {
Expand Down Expand Up @@ -125,6 +128,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
accessibilityValue={accessibilityValue}
accessibilityRole={'tab'}
accessibilityState={{ selected: isSelected }}
testID={testIDs?.[index]}
>
<Text allowFontScaling={false} style={textStyle}>
{label}
Expand Down
10 changes: 5 additions & 5 deletions packages/components/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2829,7 +2829,7 @@ __metadata:
dependencies:
"@babel/core": ^7.20.0
"@babel/plugin-proposal-export-namespace-from": ^7.18.9
"@department-of-veterans-affairs/mobile-tokens": 0.0.7
"@department-of-veterans-affairs/mobile-tokens": 0.0.10
"@expo/webpack-config": ^18.1.2
"@os-team/i18next-react-native-language-detector": ^1.0.28
"@react-native-async-storage/async-storage": ^1.19.0
Expand Down Expand Up @@ -2882,10 +2882,10 @@ __metadata:
languageName: unknown
linkType: soft

"@department-of-veterans-affairs/mobile-tokens@npm:0.0.7":
version: 0.0.7
resolution: "@department-of-veterans-affairs/mobile-tokens@npm:0.0.7"
checksum: eb1f4c756a3408a6219aaa8465aec5a2d1d926e1a49271574847c8668afe2082f8dafd21ee451becd12409262d7697c41a7ba61490a077662a14710218205b1e
"@department-of-veterans-affairs/mobile-tokens@npm:0.0.10":
version: 0.0.10
resolution: "@department-of-veterans-affairs/mobile-tokens@npm:0.0.10"
checksum: 7590c87fb87e72891fe270f9dc53be8af3d0471d43cd448ead234b40d3f1fd5612740f049c121062c2beffd2597e81fa4e705e808bf3dc3110c33fbc1213f928
languageName: node
linkType: hard

Expand Down
13 changes: 6 additions & 7 deletions packages/tokens/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
"prefix": "",
"files": [
{
"destination": "js/colors.js",
"format": "javascript/es6",
"filter": {
"attributes": {
"category": "color"
}
}
"destination": "js/tokens.js",
"format": "javascript/es6"
},
{
"format": "typescript/es6-declarations",
"destination": "index.d.ts"
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions packages/tokens/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@department-of-veterans-affairs/mobile-tokens",
"version": "0.0.7",
"version": "0.0.10",
"description": "VA Design System Mobile Token Library",
"main": "src/index.ts",
"main": "dist/js/tokens.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "style-dictionary build",
"prepack": "style-dictionary build",
Expand Down
1 change: 0 additions & 1 deletion packages/tokens/src/index.ts

This file was deleted.

Loading