Skip to content
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: 3 additions & 1 deletion .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- deploy-storybook
pull_request:
pull_request_target:
branches:
- deploy-storybook
types:
- closed

jobs:
deploy-storybook:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- release
pull_request:
pull_request_target:
branches:
- release
types:
- closed

jobs:
release:
Expand Down
2 changes: 1 addition & 1 deletion packages/carbon-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@audira/carbon-react-native",
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",
"homepage": "https://rakadoank.github.io/carbon-react-native",
"repository": "https://github.com/RakaDoank/carbon-react-native",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import {
createContext,
} from "react"

import {
I18nManager,
} from "react-native"

import type {
NotificationColor,
} from "../../../components/notification/NotificationColor"
Expand All @@ -26,5 +30,5 @@ export const GlobalConfigContext = createContext<GlobalConfigContext>({
android_buttonRippleEffect: true,
notificationColor: "high_contrast",
toastDuration: 5000,
rtl: false,
rtl: I18nManager.isRTL,
})
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
I18nManager,
} from "react-native"

import {
GlobalConfigContext,
} from "../../contexts/global-config"
Expand All @@ -6,14 +10,20 @@ import type {
GlobalConfigProviderProps,
} from "./GlobalConfigProviderProps"

const isRtl = I18nManager.isRTL

export function GlobalConfigProvider({
android_buttonRippleEffect,
notificationColor,
toastDuration,
rtl,
android_buttonRippleEffect = true,
notificationColor = "high_contrast",
toastDuration = 5000,
rtl: rtlProp,
children,
}: GlobalConfigProviderProps) {

const
rtl =
rtlProp ?? isRtl

return (
<GlobalConfigContext.Provider
value={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type {
GlobalConfigContext,
} from "../../contexts"

export interface GlobalConfigProviderProps extends GlobalConfigContext {
export interface GlobalConfigProviderProps extends Partial<GlobalConfigContext> {
children?: React.ReactNode,
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import type {
} from "./CarbonReactNativeProps"

export function CarbonReactNative({
// GlobalConfigProviderProps
android_buttonRippleEffect = true,
notificationColor = "high_contrast",
toastDuration = 5000,
rtl = false,

// ThemeProviderProps
// +++ GlobalConfigProviderProps +++
android_buttonRippleEffect,
notificationColor,
toastDuration,
rtl,
// --- GlobalConfigProviderProps ---
// +++ ThemeProviderProps +++
colorScheme,

// --- ThemeProviderProps ---
children,
}: CarbonReactNativeProps) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import type {
ThemeProviderProps,
} from "../_internal/providers"

export interface CarbonReactNativeProps extends Partial<GlobalConfigProviderProps>, ThemeProviderProps {
export interface CarbonReactNativeProps extends GlobalConfigProviderProps, ThemeProviderProps {
}
6 changes: 6 additions & 0 deletions packages/carbon-react-native/src/components/box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import type {
BoxRef,
} from "./BoxRef"

/**
* This component is a basic React Native `View` to solve
* RTL support for component level.
*
* You may use this if your app provides custom localization options.
*/
export const Box = forwardRef<BoxRef, BoxProps>(
function Box(
{
Expand Down
23 changes: 6 additions & 17 deletions packages/carbon-react-native/src/components/button/base/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Base = forwardRef<BaseRef, BaseProps>(
getIconSize(size),

iconMarginStyle =
mapIconMarginStyle[`${!!globalConfigContext.rtl}`][`${!!text}`]
mapIconMarginStyle[`${!!text}`]

return (
<Pressable
Expand Down Expand Up @@ -172,11 +172,8 @@ const
maxHeight: 48,
},

iconMarginLTR: {
marginLeft: Spacing.spacing_07,
},
iconMarginRTL: {
marginRight: Spacing.spacing_07,
iconMargin: {
marginStart: Spacing.spacing_07,
},

inlineLoading: {
Expand Down Expand Up @@ -241,19 +238,11 @@ const
},

mapIconMarginStyle: {
[RTL in `${boolean}`]: {
[HasText in `${boolean}`]: ViewProps["style"]
}
[HasText in `${boolean}`]: ViewProps["style"]
} =
{
false: {
false: null,
true: baseStyle.iconMarginLTR,
},
true: {
false: null,
true: baseStyle.iconMarginRTL,
},
false: null,
true: baseStyle.iconMargin,
},

mapStyleInButtonGroup: {
Expand Down
26 changes: 3 additions & 23 deletions packages/carbon-react-native/src/components/button/ghost/Ghost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import {
useContext,
} from "react"

import {
StyleSheet,
type TextStyle,
type ViewStyle,
import type {
TextStyle,
ViewStyle,
} from "react-native"

import {
Color,
Spacing,
} from "@audira/carbon-react-native-elements"

import * as CarbonStyleSheet from "../../../carbon-style-sheet"
Expand All @@ -38,7 +36,6 @@ export const Ghost = forwardRef<GhostRef, GhostProps>(
function Ghost(
{
text,
iconProps,
...props
},
ref,
Expand Down Expand Up @@ -71,10 +68,6 @@ export const Ghost = forwardRef<GhostRef, GhostProps>(
},
icon: mapIconColor[themeContext.colorScheme],
}}
iconProps={{
...iconProps,
style: [mapIconPLByText[`${!!text}`], iconProps?.style],
}}
/>
)

Expand Down Expand Up @@ -125,19 +118,6 @@ const
},
}),

style =
StyleSheet.create({
iconPL8: {
paddingLeft: Spacing.spacing_03,
},
}),

mapIconPLByText: Record<string, typeof style["iconPL8"] | null> =
{
false: null,
true: style.iconPL8,
},

mapIconColor: Record<ThemeContext["colorScheme"], Record<BaseColorState, string>> =
{
gray_10: {
Expand Down
8 changes: 8 additions & 0 deletions packages/carbon-react-native/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as Button from "./button"
import * as Notification from "./notification"
import * as TableToolbarButton from "./table-toolbar-button"
import * as Toggle from "./toggle"

export {
Button,
Notification,
TableToolbarButton,
Toggle,
}

Expand All @@ -31,10 +33,16 @@ export * from "./radio-button-group"
export * from "./radio-button-input"
export * from "./switch"
export * from "./table"
export * from "./table-batch-action-bar"
export * from "./table-batch-action-bar-button"
export * from "./table-cell"
export * from "./table-cell-header"
export * from "./table-cell-icon"
export * from "./table-cell-text"
export * from "./table-header"
export * from "./table-toolbar"
export * from "./table-toolbar-button"
export * from "./table-toolbar-switcher"
export * from "./table-row"
export * from "./table-row-header"
export * from "./text"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
forwardRef,
useContext,
} from "react"

import {
ScrollView as ReactNativeScrollView,
} from "react-native"

import {
GlobalConfigContext,
} from "../../_internal/contexts"

import * as CarbonStyleSheet from "../../carbon-style-sheet"

import type {
ScrollViewProps,
} from "./ScrollViewProps"

/**
* This component is a basic React Native `ScrollView` to solve
* RTL support for component level.
*
* You may use this if your app provides custom localization options.
*/
export const ScrollView = forwardRef<ReactNativeScrollView, ScrollViewProps>(
function ScrollView(
{
dir: dirProp,
style,
contentContainerStyle,
...props
},
ref,
) {

const
globalConfigContext =
useContext(GlobalConfigContext),

dir =
dirProp ??
globalConfigContext.rtl ? "rtl" : "ltr"

return (
<ReactNativeScrollView
ref={ ref }
{ ...props }
dir={ dir }
style={ [
dir == "rtl" ? CarbonStyleSheet.g.rtl : undefined,
style,
] }
contentContainerStyle={ [
dir == "rtl" ? CarbonStyleSheet.g.rtl : undefined,
contentContainerStyle,
] }
/>
)

},
) as unknown as typeof ReactNativeScrollView & ReactNativeScrollView
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type {
ScrollViewProps as Props,
} from "react-native"

export interface ScrollViewProps extends Props {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./ScrollView"
export type * from "./ScrollViewProps"
Loading
Loading