-
Notifications
You must be signed in to change notification settings - Fork 26
More nativewind friendly #1037
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
Merged
YoussefHenna
merged 2 commits into
master
from
youssef/v2-2192-make-jigsaw-component-more-nativewind-friendly
Jun 1, 2026
Merged
More nativewind friendly #1037
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @import "tailwindcss/theme.css" layer(theme); | ||
| @import "tailwindcss/preflight.css" layer(base); | ||
| @import "tailwindcss/utilities.css"; | ||
|
|
||
| @import "nativewind/theme"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /// <reference types="react-native-css/types" /> | ||
|
|
||
| // NOTE: This file should not be edited and should be committed with your source code. It is generated by react-native-css. If you need to move or disable this file, please see the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export default { | ||
| plugins: { | ||
| "@tailwindcss/postcss": {}, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| import React from "react"; | ||
| import { View, Text } from "react-native"; | ||
| import { | ||
| AudioPlayer, | ||
| CircularProgress, | ||
| CustomPinInputCell, | ||
| CustomPinInputText, | ||
| DeckSwiper, | ||
| DeckSwiperCard, | ||
| LinearProgress, | ||
| LoadingIndicator, | ||
| LottieAnimation, | ||
| Markdown, | ||
| PinInput, | ||
| Swiper, | ||
| SwiperItem, | ||
| Timer, | ||
| VideoPlayer, | ||
| WebView, | ||
| } from "@draftbit/ui"; | ||
| import { LoadingIndicatorType } from "@draftbit/core/lib/typescript/src/components/LoadingIndicator"; | ||
| import Section, { Container } from "./Section"; | ||
|
|
||
| const PROGRESS_VALUE = 65; | ||
|
|
||
| const NativeWindExample: React.FC<{ theme?: any }> = () => { | ||
| const [pinValue, setPinValue] = React.useState(""); | ||
| const timerRef = React.useRef<any>(null); | ||
|
|
||
| return ( | ||
| <Container style={{}}> | ||
| <Section title="AudioPlayer" style={{}}> | ||
| <AudioPlayer | ||
| className="rounded-2xl bg-gray-100 h-12 border-0 w-100" | ||
| source={{ | ||
| uri: "https://static.draftbit.com/audio/intro-to-draftbit-audio.mp3", | ||
| }} | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="CircularProgress" style={{}}> | ||
| <View className="items-center flex-row"> | ||
| <CircularProgress className="w-60" value={PROGRESS_VALUE} /> | ||
| <CircularProgress | ||
| className="w-40 ml-20" | ||
| color="rgb(99,102,241)" | ||
| trackColor="rgb(224,231,255)" | ||
| value={PROGRESS_VALUE} | ||
| /> | ||
| </View> | ||
| </Section> | ||
|
|
||
| <Section | ||
| title="DeckSwiper + DeckSwiperCard" | ||
| style={{ paddingBottom: 30 }} | ||
| > | ||
| <DeckSwiper className="w-100" visibleCardCount={2}> | ||
| <DeckSwiperCard className="bg-red-100 p-10 items-center justify-center rounded-xl"> | ||
| <Text className="text-base font-semibold text-red-700">Card 1</Text> | ||
| </DeckSwiperCard> | ||
| <DeckSwiperCard className="bg-blue-100 p-10 items-center justify-center rounded-xl"> | ||
| <Text className="text-base font-semibold text-blue-700"> | ||
| Card 2 | ||
| </Text> | ||
| </DeckSwiperCard> | ||
| <DeckSwiperCard className="bg-green-100 p-10 items-center justify-center rounded-xl"> | ||
| <Text className="text-base font-semibold text-green-700"> | ||
| Card 3 | ||
| </Text> | ||
| </DeckSwiperCard> | ||
| </DeckSwiper> | ||
| </Section> | ||
|
|
||
| <Section title="LinearProgress" style={{}}> | ||
| <LinearProgress className="w-100" value={PROGRESS_VALUE} /> | ||
| <LinearProgress | ||
| className="w-100 mt-3" | ||
| color="rgb(99,102,241)" | ||
| trackColor="rgb(224,231,255)" | ||
| thickness={12} | ||
| value={PROGRESS_VALUE} | ||
| /> | ||
| <LinearProgress | ||
| className="w-150 mt-10" | ||
| thickness={8} | ||
| trackThickness={8} | ||
| dashWidth={12} | ||
| dashGap={8} | ||
| value={PROGRESS_VALUE} | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="LoadingIndicator" style={{}}> | ||
| <View className="flex-row"> | ||
| <LoadingIndicator | ||
| className="m-2 border-2 p-4" | ||
| type={LoadingIndicatorType.circle} | ||
| /> | ||
| <LoadingIndicator className="m-2" type={LoadingIndicatorType.wave} /> | ||
|
|
||
| <LoadingIndicator | ||
| className="m-2" | ||
| type={LoadingIndicatorType.bounce} | ||
| /> | ||
|
|
||
| <LoadingIndicator className="m-2" type={LoadingIndicatorType.pulse} /> | ||
| </View> | ||
| </Section> | ||
|
|
||
| <Section title="LottieAnimation" style={{}}> | ||
| <LottieAnimation | ||
| className="w-48 h-48 border-2" | ||
| source={require("./assets/lottie_animation_example.json")} | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="Markdown" style={{}}> | ||
| <Markdown className="w-200"> | ||
| { | ||
| "## NativeWind\n\nThis is **bold** and _italic_ text styled via `className`.\n\n- Item one\n- Item two\n- Item three" | ||
| } | ||
| </Markdown> | ||
| </Section> | ||
|
|
||
| <Section title="PinInput (default)" style={{}}> | ||
| <PinInput | ||
| className="border-2 w-100" | ||
| value={pinValue} | ||
| onChangeText={setPinValue} | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section | ||
| title="PinInput (CustomPinInputCell + CustomPinInputText)" | ||
| style={{}} | ||
| > | ||
| <PinInput | ||
| value={pinValue} | ||
| onChangeText={setPinValue} | ||
| className="w-100" | ||
| renderItem={({ cellValue, isFocused }) => ( | ||
| <CustomPinInputCell | ||
| className={`w-14 h-14 mx-1.5 rounded-xl bg-white items-center justify-center ${ | ||
| isFocused ? "border-2 border-red-500" : "border border-gray-300" | ||
| }`} | ||
| > | ||
| <CustomPinInputText | ||
| className={`text-xl font-bold ${ | ||
| isFocused ? "text-indigo-500" : "text-gray-800" | ||
| }`} | ||
| isFocused={isFocused} | ||
| > | ||
| {cellValue} | ||
| </CustomPinInputText> | ||
| </CustomPinInputCell> | ||
| )} | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="Swiper + SwiperItem" style={{}}> | ||
| <Swiper | ||
| keyExtractor={(key) => key} | ||
| className="w-100 h-48" | ||
| vertical={false} | ||
| loop | ||
| > | ||
| <SwiperItem className="items-center justify-center bg-red-100"> | ||
| <Text className="text-lg font-semibold text-red-700">Slide 1</Text> | ||
| </SwiperItem> | ||
| <SwiperItem className="items-center justify-center bg-indigo-100"> | ||
| <Text className="text-lg font-semibold text-indigo-700"> | ||
| Slide 2 | ||
| </Text> | ||
| </SwiperItem> | ||
| <SwiperItem className="items-center justify-center bg-green-100"> | ||
| <Text className="text-lg font-semibold text-green-700"> | ||
| Slide 3 | ||
| </Text> | ||
| </SwiperItem> | ||
| </Swiper> | ||
| </Section> | ||
|
|
||
| <Section title="Timer" style={{}}> | ||
| <Timer | ||
| ref={timerRef} | ||
| className="text-5xl text-red-800" | ||
| initialTime={0} | ||
| format="mm:ss" | ||
| countDirection="up" | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="VideoPlayer" style={{}}> | ||
| <VideoPlayer | ||
| className="w-100 h-56 rounded-xl overflow-hidden" | ||
| source={{ | ||
| uri: "http://static.draftbit.com/videos/intro-to-draftbit.mp4", | ||
| }} | ||
| useNativeControls | ||
| resizeMode="cover" | ||
| /> | ||
| </Section> | ||
|
|
||
| <Section title="WebView" style={{}}> | ||
| <WebView | ||
| className="w-200 h-100 rounded-xl overflow-hidden" | ||
| source={{ uri: "https://docs.expo.io/" }} | ||
| /> | ||
| </Section> | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default NativeWindExample; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conditionally omitting the default background and border styles when
classNameis present is highly fragile. If a developer passes aclassNamefor an unrelated style (such as padding or margins, e.g.,className="p-4"), the component will completely lose its default background and border colors. Always include the default styles in thestylearray; NativeWind's compiled styles fromclassNamewill naturally override these defaults because they are merged/appended at the end of the style array.