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

feat(solid): initial draft implementation #1096

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
18475d5
feat(solid): initial
raveclassic Sep 3, 2022
82f0a87
fix(solid): fix build
raveclassic Sep 3, 2022
29e5fd4
build(solid): migrate to babel-preset-jest
raveclassic Sep 5, 2022
433f121
build(solid): transpile tests with linaria and solid
raveclassic Sep 5, 2022
e8b0acb
test(solid): add initial tests
raveclassic Sep 5, 2022
a07fa50
test(solid): add manual transpilation test
raveclassic Sep 5, 2022
f6ff5da
test(solid): add manual transpilation test
raveclassic Sep 6, 2022
76593ea
build: update lockfile
raveclassic Oct 23, 2022
f363ba4
build: reset lockfile
raveclassic Oct 23, 2022
241b2ff
build(solid): cleanup dependencies
raveclassic Oct 23, 2022
3879f2f
build(solid): add @jest/transform
raveclassic Oct 23, 2022
d984d00
test(solid): custom jest transformer for tests
raveclassic Oct 23, 2022
80adc16
test(solid): render test components
raveclassic Oct 23, 2022
e29558c
Merge branch 'master' into solid
raveclassic Nov 25, 2022
b5ce464
build(solid): reset lockfile to master
raveclassic Nov 25, 2022
dfc98d5
build(solid): update lockfile for solid package
raveclassic Nov 25, 2022
0cda584
build(solid): lock dev babel dependencies to repo versions
raveclassic Nov 25, 2022
6454b58
fix(solid): align processor constructor with the latest updates in re…
raveclassic Nov 25, 2022
530a670
build(solid): reset lockfile to master
raveclassic Nov 25, 2022
389ff64
test(solid): drop tests
raveclassic Nov 25, 2022
7d0ee92
build(solid): bring dependencies back
raveclassic Nov 25, 2022
e90bc5d
feat(examples/solid): add initial example
raveclassic Nov 25, 2022
67ad092
build(solid): align build steps with react package
raveclassic Nov 25, 2022
276f023
build(examples/solid): downgrade vite to be aligned with @linaria/vite
raveclassic Nov 25, 2022
f76a554
chore(solid): fix exports
raveclassic Nov 25, 2022
01e844d
feat(examples/solid): finish example
raveclassic Nov 25, 2022
3e55c5c
chore(solid): remove processor export
raveclassic Nov 25, 2022
97b721a
build(solid): use tsconfig.lib.json in tsup
raveclassic Nov 26, 2022
ae9dd9c
test(solid): add type-level tests
raveclassic Nov 26, 2022
1258690
chore(solid): drop linaria config
raveclassic Nov 26, 2022
f155943
build(solid): add node typings
raveclassic Nov 26, 2022
8669970
fix(react): fix additional props signature
raveclassic Nov 27, 2022
5ca500c
feat(solid): require class prop
raveclassic Nov 27, 2022
10a8a95
feat(solid): require style prop
raveclassic Nov 27, 2022
7630006
Merge branch 'master' into solid
raveclassic Nov 27, 2022
b03f733
build(solid): upgrade @babel/types@^7.20.2
raveclassic Nov 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');

// Workaround for https://github.com/import-js/eslint-plugin-import/issues/1810
const noUnresolved = ['error', { ignore: ['@linaria/*'] }];

Expand Down Expand Up @@ -147,7 +149,7 @@ module.exports = {
'plugin:import/typescript',
],
parserOptions: {
project: './tsconfig.eslint.json',
project: path.resolve(__dirname, './tsconfig.eslint.json'),
},
rules: {
'import/extensions': 0,
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ esm/
types/
dist/
build/
tsconfig.tsbuildinfo
*.tsbuildinfo

.linaria-cache

# IntelliJ IDEA
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Zero-runtime CSS in JS library.
- Use **JavaScript for logic**, no CSS preprocessor needed
- Optionally use any **CSS preprocessor** such as Sass or PostCSS
- Supports **atomic styles** with `@linaria/atomic`
- Supports [solidjs](https://solidjs.com/) with `@linaria/sollid`

**[Why use Linaria](/docs/BENEFITS.md)**

Expand Down
7 changes: 0 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,5 @@ module.exports = {
},
},
},
{
/**
* we have to transpile JSX in tests
*/
test: /\/(__tests__|__fixtures__|packages\/teskit\/src)\//,
presets: ['@babel/preset-react'],
},
],
};
2 changes: 2 additions & 0 deletions examples/solid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
21 changes: 21 additions & 0 deletions examples/solid/.linariarc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
rules: [
{
action: require.resolve('@linaria/shaker'),
},
{
test: /\/node_modules\//,
action: 'ignore',
},
{
test: (filename, code) => {
if (!/\/node_modules\//.test(filename)) {
return false;
}

return /(?:^|\n|;)\s*(?:export|import)\s+/.test(code);
},
action: require.resolve('@linaria/shaker'),
},
],
};
34 changes: 34 additions & 0 deletions examples/solid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Usage

Those templates dependencies are maintained via [pnpm](https://pnpm.io) via `pnpm up -Lri`.

This is the reason you see a `pnpm-lock.yaml`. That being said, any package manager will work. This file can be safely be removed once you clone a template.

```bash
$ npm install # or pnpm install or yarn install
```

### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)

## Available Scripts

In the project directory, you can run:

### `npm dev` or `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>

### `npm run build`

Builds the app for production to the `dist` folder.<br>
It correctly bundles Solid in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

## Deployment

You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.)
16 changes: 16 additions & 0 deletions examples/solid/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="/src/index.tsx" type="module"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions examples/solid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "vite-template-solid",
"version": "0.0.0",
"description": "",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.20.2",
"@linaria/shaker": "workspace:^",
"@linaria/vite": "workspace:^",
"babel-preset-solid": "^1.6.2",
"babel-preset-typescript": "7.0.0-alpha.19",
"vite": "3.1.8",
"vite-plugin-solid": "^2.4.0"
},
"dependencies": {
"@linaria/core": "workspace:^",
"@linaria/solid": "workspace:^",
"solid-js": "^1.6.2"
}
}
76 changes: 76 additions & 0 deletions examples/solid/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import type { Component } from 'solid-js';

import logo from './logo.svg';
import { styled } from '@linaria/solid';
import {css} from '@linaria/core'

const globals = css`
:global() {
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
}
`;

const AppStyled = styled.div`
text-align: center;
`

const HeaderStyled = styled.header`
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
`

const LogoStyled = styled.img`
animation: logo-spin infinite 20s linear;
height: 40vmin;
pointer-events: none;

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
`

const LinkStyled = styled.a`
color: #b318f0;
`

const App: Component = () => {
return (
<AppStyled class={globals}>
<HeaderStyled>
<LogoStyled src={logo} alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<LinkStyled
href="https://github.com/solidjs/solid"
target="_blank"
rel="noopener noreferrer"
>
Learn Solid
</LinkStyled>
</HeaderStyled>
</AppStyled>
);
};

export default App;
Binary file added examples/solid/src/assets/favicon.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/solid/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* @refresh reload */
import { render } from 'solid-js/web';

import App from './App';

render(() => <App />, document.getElementById('root') as HTMLElement);
1 change: 1 addition & 0 deletions examples/solid/src/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples/solid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"types": ["vite/client"],
"noEmit": true,
"isolatedModules": true
}
}
29 changes: 29 additions & 0 deletions examples/solid/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import linaria from '@linaria/vite';

export default defineConfig({
plugins: [
{
...linaria({
include: ['./src/**/*.tsx'],
babelOptions: {
overrides: [
{
test: ['./src/**/*.tsx'],
presets: ['typescript', 'solid'],
},
],
},
}),
enforce: 'pre'
},
solidPlugin(),
],
server: {
port: 3000,
},
build: {
target: 'esnext',
},
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-expect-type": "^0.2.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './utils/collectTemplateDependencies';
export { default as collectTemplateDependencies } from './utils/collectTemplateDependencies';
export { default as withLinariaMetadata } from './utils/withLinariaMetadata';
export { default as Module } from './module';
export { default as transform } from './transform';
export { default as transform, transformSync } from './transform';
export * from './types';
export { default as loadLinariaOptions } from './transform-stages/helpers/loadLinariaOptions';
export type { PluginOptions } from './transform-stages/helpers/loadLinariaOptions';
Expand Down
12 changes: 9 additions & 3 deletions packages/react/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const config = require('../../babel.config');

module.exports = config;
module.exports = {
extends: '../../babel.config',
overrides: [
{
test: ['__tests__/**/*.tsx'],
presets: ['@babel/preset-react'],
},
],
};
12 changes: 12 additions & 0 deletions packages/solid/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["../../.eslintrc.js"],
"overrides": [
{
"files": ["__dtslint__/**/*.tsx", "__dtslint__/**/*.ts"],
"plugins": ["expect-type"],
"extends": [
"plugin:eslint-plugin-expect-type/recommended"
]
}
]
}
46 changes: 46 additions & 0 deletions packages/solid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<p align="center">
<img alt="Linaria" src="https://raw.githubusercontent.com/callstack/linaria/HEAD/website/assets/linaria-logo@2x.png" width="496">
</p>

<p align="center">
Zero-runtime CSS in JS library.
</p>

---

# @linaria/solid

### 📖 Please refer to the [GitHub](https://github.com/callstack/linaria#readme) for full documentation.

**[Why use Linaria](../../docs/BENEFITS.md)**

## Features

- supports a subset of `styled-components` syntax (`styled.div`, `styled(Component)`, property interpolations)

## Limitations

- does not support theming through arguments to property interpolations (yet)

## Installation

```sh
npm install @linaria/babel-preset @linaria/solid babel-preset-solid
```

or

```sh
yarn install @linaria/babel-preset @linaria/solid babel-preset-solid
```

## Configuration

For the time of this writing, `@linaria/solid` supports configuration only via babel configuration.
Just add `solid` to the `"presets"` section in your `babel.config.js` _after_ `"@linaria"`:

```json
{
"presets": ["@linaria", "solid"]
}
```