Skip to content
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

Add preset for SolidJS #817

Merged
merged 6 commits into from Jul 23, 2023
Merged

Add preset for SolidJS #817

merged 6 commits into from Jul 23, 2023

Conversation

ben-rogerson
Copy link
Owner

@ben-rogerson ben-rogerson commented Jul 13, 2023

Twin now has support for SolidJS πŸŽ‰

When we define the solid preset like this:

// babel-plugin-macros.config.js
module.exports = {
  twin: {
    preset: 'solid',
  },
}

Or in package.json:

// package.json
"babelMacros": {
  "twin": {
    "preset": "solid"
  }
},

Twin will use the imports from solid-styled-components - the official css-in-js library provided by the SolidJS team.

Here are the conversions that happen during common styling patterns:

tw prop

function Component() {
  return <div tw="block" />
}
// ↓ ↓ ↓ ↓ ↓ ↓
import { styled } from "solid-styled-components";
const TwComponent = styled("div")({ "display": "block" });
function Component() {
  return <TwComponent data-tw="block" />;
}

css prop

const Component = ({ children }) => (
  <div css={[]}>{children}</div>
)
// ↓ ↓ ↓ ↓ ↓ ↓
import { styled } from "solid-styled-components";
const TwComponent = styled("div")([]);
const Component = ({ children }) => (
  <TwComponent>{children}</TwComponent>
)

tw.div

import tw from "twin.macro"
const Component = tw.div`block`
// ↓ ↓ ↓ ↓ ↓ ↓
import { styled } from "solid-styled-components";
const Component = styled("div")({ "display": "block" });

styled.div

import { styled } from "twin.macro"
const Component = styled.div([])
// ↓ ↓ ↓ ↓ ↓ ↓
import { styled } from "solid-styled-components";
const Component = styled("div")([]);

More

Related #398

@ben-rogerson ben-rogerson merged commit e438582 into master Jul 23, 2023
@ben-rogerson ben-rogerson deleted the feature/preset-for-solid-js branch July 23, 2023 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant