Skip to content

Commit 2083c8a

Browse files
committed
Add Box component to fix RTL Direction Automatically, Provide Style Sheets
1 parent a9b2dd6 commit 2083c8a

78 files changed

Lines changed: 652 additions & 351 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/carbon-react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@audira/carbon-react-native",
3-
"version": "1.0.0-beta.19",
3+
"version": "1.0.0-beta.20",
44
"license": "MIT",
55
"homepage": "https://rakadoank.github.io/carbon-react-native",
66
"repository": "https://github.com/RakaDoank/carbon-react-native",

packages/carbon-react-native/src/_internal/style-sheets/common-style-sheet.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/carbon-react-native/src/_internal/style-sheets/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/carbon-react-native/src/components/accordion/_Header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import {
1212
Color,
1313
} from "@audira/carbon-react-native-elements"
1414

15-
import {
16-
FlexStyleSheet,
17-
} from "../../_internal/style-sheets"
18-
1915
import {
2016
CarbonStyleSheet,
2117
} from "../../carbon-style-sheet"
@@ -24,6 +20,10 @@ import {
2420
ThemeContext,
2521
} from "../../contexts"
2622

23+
import {
24+
FlexStyleSheet,
25+
} from "../../style-sheets"
26+
2727
import type {
2828
Size as ButtonSize,
2929
} from "../button/Size"

packages/carbon-react-native/src/components/accordion/_HeaderBorder.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import {
1212
Spacing,
1313
} from "@audira/carbon-react-native-elements"
1414

15-
import {
16-
CommonStyleSheet,
17-
} from "../../_internal/style-sheets"
18-
1915
import {
2016
CarbonStyleSheet,
2117
} from "../../carbon-style-sheet"
@@ -24,6 +20,11 @@ import {
2420
ThemeContext,
2521
} from "../../contexts"
2622

23+
import {
24+
PositionStyleSheet,
25+
WidthStyleSheet,
26+
} from "../../style-sheets"
27+
2728
export interface HeaderBorderProps {
2829
/**
2930
* https://carbondesignsystem.com/components/accordion/style/#flush-alignment
@@ -42,15 +43,15 @@ export function HeaderBorder({
4243
return (
4344
<View
4445
style={ [
45-
CommonStyleSheet.absolute,
46+
PositionStyleSheet.absolute,
4647
style.borderBox,
4748
carbonStyle.borderBox,
4849
flushAlignment
4950
? {
5051
left: Spacing.spacing_05,
5152
right: Spacing.spacing_05,
5253
}
53-
: CommonStyleSheet.w_full,
54+
: WidthStyleSheet.w_full,
5455
styleProp,
5556
] }
5657
/>

packages/carbon-react-native/src/components/accordion/_Item.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import {
2121
} from "../../_internal/contexts"
2222

2323
import {
24-
CommonStyleSheet,
25-
} from "../../_internal/style-sheets"
24+
DirectionStyleSheet,
25+
} from "../../style-sheets"
2626

2727
import {
2828
Collapsible,
@@ -151,7 +151,7 @@ export const Item = forwardRef<AccordionItemRef, AccordionItemProps>(
151151
open={ open }
152152
dir={ globalConfigContext.rtl ? "rtl" : undefined }
153153
contentContainerStyle={ [
154-
globalConfigContext.rtl ? CommonStyleSheet.rtl : undefined,
154+
globalConfigContext.rtl ? DirectionStyleSheet.rtl : undefined,
155155
accordionContext.collapsibleContentContainerStyle,
156156
style.panel,
157157
] }
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {
2+
forwardRef,
3+
useContext,
4+
} from "react"
5+
6+
import {
7+
View,
8+
} from "react-native"
9+
10+
import {
11+
GlobalConfigContext,
12+
} from "../../_internal/contexts"
13+
14+
import {
15+
DirectionStyleSheet,
16+
} from "../../style-sheets"
17+
18+
import type {
19+
BoxProps,
20+
} from "./BoxProps"
21+
22+
import type {
23+
BoxRef,
24+
} from "./BoxRef"
25+
26+
export const Box = forwardRef<BoxRef, BoxProps>(
27+
function Box(
28+
{
29+
dir: dirProp,
30+
style,
31+
...props
32+
},
33+
ref,
34+
) {
35+
36+
const
37+
globalConfigContext =
38+
useContext(GlobalConfigContext),
39+
40+
dir =
41+
dirProp ??
42+
globalConfigContext.rtl ? "rtl" : "ltr"
43+
44+
return (
45+
<View
46+
ref={ ref }
47+
{ ...props }
48+
dir={ dir }
49+
style={ [
50+
dir == "rtl" ? DirectionStyleSheet.rtl : undefined,
51+
style,
52+
] }
53+
/>
54+
)
55+
56+
},
57+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type {
2+
ViewProps,
3+
} from "react-native"
4+
5+
export interface BoxProps extends ViewProps {
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type {
2+
View,
3+
} from "react-native"
4+
5+
export interface BoxRef extends View {
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "./Box"
2+
export type * from "./BoxProps"
3+
export type * from "./BoxRef"

0 commit comments

Comments
 (0)