-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-native): more complex twrnc style cases (#1505)
* feat: support more complex styling in twrnc * chore: linting
- Loading branch information
Showing
6 changed files
with
166 additions
and
21 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 @@ | ||
--- | ||
'@builder.io/mitosis': patch | ||
--- | ||
|
||
feat: support more complex RN styling with twrnc |
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
27 changes: 27 additions & 0 deletions
27
packages/core/src/__tests__/data/react-native/twrnc-state-complex-styled-component.raw.tsx
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,27 @@ | ||
import { useStore } from '@builder.io/mitosis'; | ||
import { clsx } from 'clsx'; | ||
|
||
type ButtonType = 'primary' | 'secondary'; | ||
|
||
interface ButtonProps { | ||
type: ButtonType; | ||
onClick: () => void; | ||
children: any; | ||
} | ||
|
||
export default function Button(props: ButtonProps) { | ||
const state = useStore({ | ||
get buttonClasses() { | ||
return clsx('px-4 py-2 rounded transition-colors', { | ||
'bg-blue-500 hover:bg-blue-600 text-white': props.type === 'primary', | ||
'bg-gray-300 hover:bg-gray-400 text-black': props.type === 'secondary', | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<button class={state.buttonClasses} onClick={props.onClick}> | ||
{props.children} | ||
</button> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/core/src/__tests__/data/react-native/twrnc-state-styled-component.raw.tsx
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,7 @@ | ||
import { useState } from '@builder.io/mitosis'; | ||
|
||
export default function MyBasicComponent() { | ||
const [classState, setClassState] = useState('testClassName'); | ||
|
||
return <div class={classState}>Hello! I can run in React, Vue, Solid, or Liquid!</div>; | ||
} |
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