-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WIP] feat: add NativeWind plugin * chore: setup * fix: use nativewind import for now * feat: working on webpack * chore: webpack setup alignment * fix: hmr with swc/rspack * chore: cleanup and comments * chore: cleanup tsconfig * chore: cleanup in tester app * fix: double stringify * chore: update Podfile.lock * feat: add examples for NativeWind functionality * feat: add a demo using NativeWind with RN Reusables * feat: add several more NativeWind features to tester app * fix: don't set ScriptManager storage in dev * feat: set importSource to nativewind * chore: remove hardcoded nativewind in core * chore: add missing clsx * chore: make webpack tester app work with nativewind * chore: update webpack config in tester app * chore: cleanup * chore: update podfile locks * chore: update package.json * chore: update lockfile * chore: remove redundant README.md in tester-app * chore: update README.md * chore: update babel config in tester app * chore: add changeset --------- Co-authored-by: Jakub Romanczyk <[email protected]>
- Loading branch information
1 parent
32ae1e0
commit d9d64ef
Showing
34 changed files
with
1,510 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
--- | ||
"@callstack/repack": minor | ||
--- | ||
|
||
Add support for NativeWind through a dedicated optional plugin called `@callstack/repack-plugin-nativewind` |
This file contains 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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
module.exports = { | ||
presets: ['module:@react-native/babel-preset'], | ||
comments: true, | ||
plugins: [ | ||
[ | ||
'@babel/plugin-transform-react-jsx', | ||
{ | ||
runtime: 'automatic', | ||
importSource: 'nativewind', | ||
}, | ||
], | ||
], | ||
}; |
This file contains 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,26 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
.custom-style-test { | ||
color: mediumpurple; | ||
} | ||
|
||
.calc-element { | ||
width: calc(var(--my-variable) - (20px + 2rem)); | ||
} | ||
|
||
:root { | ||
--H: 200; | ||
--S: 50%; | ||
--L: 40%; | ||
--color-values: purple; | ||
} | ||
|
||
.color-element { | ||
background-color: hsl( | ||
calc(var(--H) + 20), | ||
calc(var(--S) - 10%), | ||
calc(var(--L) + 30%) | ||
); | ||
} |
This file contains 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 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 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="nativewind/types" /> | ||
|
||
// NOTE: This file should not be edited and should be committed with your source code. It is generated by NativeWind. |
This file contains 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 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 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 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,16 @@ | ||
import { StyleSheet, Text, View } from 'react-native'; | ||
|
||
export default function Basic() { | ||
return ( | ||
<View className="bg-blue-100 p-5 rounded-full" style={styles.container}> | ||
<Text className="custom-style-test">Colored through CSS!</Text> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
}, | ||
}); |
This file contains 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,29 @@ | ||
import { Text } from 'react-native'; | ||
|
||
const variantStyles = { | ||
default: 'rounded', | ||
primary: 'bg-blue-500 text-white', | ||
secondary: 'bg-white-500 text-black', | ||
}; | ||
|
||
type Props = { | ||
variant: keyof typeof variantStyles; | ||
className?: string; | ||
} & React.ComponentProps<typeof Text>; | ||
|
||
export default function ComponentWithVariants({ | ||
variant, | ||
className, | ||
...props | ||
}: Props) { | ||
return ( | ||
<Text | ||
className={` | ||
${variantStyles.default} | ||
${variantStyles[variant]} | ||
${className} | ||
`} | ||
{...props} | ||
/> | ||
); | ||
} |
This file contains 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,10 @@ | ||
import { Text } from 'react-native'; | ||
|
||
export default function CustomComponent({ className }: { className: string }) { | ||
const defaultStyles = 'p-2 text-black dark:text-white'; | ||
return ( | ||
<Text className={`${defaultStyles} ${className}`}> | ||
I am a custom component | ||
</Text> | ||
); | ||
} |
This file contains 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,13 @@ | ||
import { colorScheme } from 'nativewind'; | ||
import { Button } from 'react-native'; | ||
|
||
export default function DarkMode() { | ||
return ( | ||
<Button | ||
onPress={() => { | ||
colorScheme.set('dark'); | ||
}} | ||
title="Toggle dark mode" | ||
/> | ||
); | ||
} |
This file contains 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,15 @@ | ||
import { vars } from 'nativewind'; | ||
import { Text, View } from 'react-native'; | ||
|
||
export default function FuncsDirs() { | ||
return ( | ||
<> | ||
<View style={vars({ '--my-custom-color': 'green' })}> | ||
<Text className="text-custom">Custom color</Text> | ||
</View> | ||
<View className="p-2 calc-element color-element"> | ||
<Text>Calculated size</Text> | ||
</View> | ||
</> | ||
); | ||
} |
This file contains 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,22 @@ | ||
import { View } from 'react-native'; | ||
import Basic from './Basic.tsx'; | ||
import ComponentWithVariants from './ComponentWithVariants.tsx'; | ||
import CustomComponent from './CustomComponent.tsx'; | ||
import DarkMode from './DarkMode.tsx'; | ||
import FuncsDirs from './FuncsDirs.tsx'; | ||
import Responsive from './Responsive.tsx'; | ||
import Reusables from './Reusables.tsx'; | ||
|
||
export function NativeWindView() { | ||
return ( | ||
<View className="gap-4 p-2"> | ||
<Basic /> | ||
<Responsive /> | ||
<CustomComponent className="bg-green-600" /> | ||
<ComponentWithVariants variant="primary" className="bg-yellow-500" /> | ||
<Reusables /> | ||
<DarkMode /> | ||
<FuncsDirs /> | ||
</View> | ||
); | ||
} |
This file contains 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,9 @@ | ||
import { Text, View } from 'react-native'; | ||
|
||
export default function Responsive() { | ||
return ( | ||
<View className="p-2 bg-orange-500 sm:bg-green-500 md:bg-red-500"> | ||
<Text className="text-white">Responsive style based on width!</Text> | ||
</View> | ||
); | ||
} |
This file contains 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,10 @@ | ||
import { Button } from './ui/Button'; | ||
import { Text } from './ui/Text'; | ||
|
||
export default function Reusables() { | ||
return ( | ||
<Button variant="primary" className="bg-purple-700"> | ||
<Text className="text-white">I am a button from RN Reusables</Text> | ||
</Button> | ||
); | ||
} |
Oops, something went wrong.