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

Fix Storybook web #17

Merged
merged 12 commits into from
Sep 14, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ coverage

.yarn/*
.yarn/cache
packages/components/.yarn/install-state.gz
packages/components/.yarn/cache

!.yarn/patches
Expand Down
1 change: 1 addition & 0 deletions packages/components/.storybook/web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = {
builder: 'webpack5',
},
framework: '@storybook/react',
staticDirs: ['../../src/assets'],
}
12 changes: 12 additions & 0 deletions packages/components/.storybook/web/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<style>
@font-face {
font-family: 'SourceSansPro-Regular';
src: url('fonts/SourceSansPro/SourceSansPro-Regular.ttf');
}

@font-face {
font-family: 'SourceSansPro-Bold';
src: url('fonts/SourceSansPro/SourceSansPro-Bold.ttf');
}

</style>
Binary file removed packages/components/.yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"storybook:deploy": "yarn storybook:build && gh-pages -d storybook-static",
"storybook:generate": "sb-rn-get-stories --config-path .storybook/native",
"storybook:watch": "sb-rn-watcher --config-path .storybook/native",
"storybook:web": "start-storybook --config-dir .storybook/web -p 6006",
"storybook:web": "STORYBOOK_WEB=true start-storybook --config-dir .storybook/web -p 6006",
"test": "jest --coverage",
"test:watch": "jest --watch"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const meta: Meta<SegmentedControlProps> = {
decorators: [
(Story) => (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Story />
{Story()}
</View>
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'react-native'
import { useTranslation } from 'react-i18next'
import React, { FC, useEffect } from 'react'
import styled from 'styled-components'
import styled from 'styled-components/native'

import { ComponentWrapper } from '../../wrapper'

Expand Down Expand Up @@ -83,7 +83,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
}

const viewStyle: ViewStyle = {
alignSelf: 'baseline',
alignSelf: 'stretch',
backgroundColor: inactiveBgColor,
borderRadius: 8,
flexDirection: 'row',
Expand Down Expand Up @@ -134,7 +134,8 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
accessibilityHint={a11yHints ? a11yHints[index] : ''}
accessibilityValue={accessibilityValue}
accessibilityRole={'tab'}
accessibilityState={{ selected: isSelected }}>
accessibilityState={{ selected: isSelected }}
>
<Text allowFontScaling={false} style={textStyle}>
{label}
</Text>
Expand Down
9 changes: 7 additions & 2 deletions packages/components/src/utils/translation/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ export const resources = {
}

// Initialize the internationalization library

// Use RNLanguageDetector only if mobile
if (process.env.STORYBOOK_WEB !== 'true') {
i18n.use(RNLanguageDetector)
}
Comment on lines +14 to +16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need an alternative library for web down the line but we don't have any translations right now.



i18n
.use(RNLanguageDetector)
.use(initReactI18next)
.init({
resources,
Expand All @@ -26,5 +32,4 @@ i18n
useSuspense: true,
},
})

export default i18n