{"id":13533163,"url":"https://github.com/LXSMNSYC/solid-sfc","last_synced_at":"2025-04-01T21:31:58.921Z","repository":{"id":54677216,"uuid":"430674145","full_name":"lxsmnsyc/solid-sfc","owner":"lxsmnsyc","description":"Experimental SFC compiler for SolidJS","archived":false,"fork":false,"pushed_at":"2022-05-25T16:43:51.000Z","size":832,"stargazers_count":26,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-01T14:03:24.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lxsmnsyc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-22T11:11:02.000Z","updated_at":"2024-10-25T15:39:28.000Z","dependencies_parsed_at":"2022-08-13T23:40:39.167Z","dependency_job_id":null,"html_url":"https://github.com/lxsmnsyc/solid-sfc","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fsolid-sfc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fsolid-sfc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fsolid-sfc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fsolid-sfc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxsmnsyc","download_url":"https://codeload.github.com/lxsmnsyc/solid-sfc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222774597,"owners_count":17035752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:17.128Z","updated_at":"2024-11-02T20:31:15.841Z","avatar_url":"https://github.com/lxsmnsyc.png","language":"TypeScript","funding_links":[],"categories":["📦 Components \u0026 Libraries"],"sub_categories":["DX"],"readme":"# solid-sfc\n\n\u003e An experimental SFC syntax for SolidJS, extends [`solid-labels`](https://github.com/lxsmnsyc/solid-labels)\n\n[![NPM](https://img.shields.io/npm/v/solid-sfc.svg)](https://www.npmjs.com/package/solid-sfc) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n\n## Install\n\n```bash\nnpm install solid-sfc\n```\n\n```bash\nyarn add solid-sfc\n```\n\n```bash\npnpm add solid-sfc\n```\n\n## Usage\n\n### Basic example\n\n```jsx\n// Required for files that do not end in `.solid.(t|j)sx?`\n'use solid-sfc';\n\nlet count = $signal(0);\nlet message = $memo(`Count: ${count}`);\n\neffect: {\n  console.log(message);\n};\n\n// Export default is synonymous to \"return\".\nexport default \u003ch1\u003e{message}\u003c/h1\u003e;\n```\n\n### `\u003csolid:fragment\u003e`, `\u003csolid:slot\u003e` and `\u003csolid:children\u003e`\n\nIf a component accepts a property that renders an element, you can use `\u003csolid:fragment\u003e` to render that property's element for the component to receive. `\u003csolid:fragment\u003e` has a single attribute, `name` which is used to define the fragment's key in the props of that component.\n\n```jsx\n\u003csolid:suspense\u003e\n  \u003csolid:fragment name=\"fallback\"\u003e\n    \u003ch1\u003eLoading...\u003c/h1\u003e\n  \u003c/solid:fragment\u003e\n  \u003cProfile /\u003e\n\u003c/solid:suspense\u003e\n```\n\nWhich is equivalent to\n\n```jsx\n\u003cSuspense fallback={\u003ch1\u003eLoading\u003c/h1\u003e}\u003e\n  \u003cProfile /\u003e\n\u003c/Suspense\u003e\n```\n\nYou can use `\u003csolid:slot\u003e` to render the received fragment on the component's side. `\u003csolid:slot\u003e` also has the `name` attribute to pick from the props.\n\n```jsx\n/* Example.solid.jsx */\nexport default \u003csolid:slot name=\"example\" /\u003e\n\n/* ParentExample.solid.jsx */\nimport Example from './Example.solid';\n\nexport default (\n  \u003cExample\u003e\n    \u003csolid:fragment name=\"example\"\u003e\n      \u003ch1\u003eHello World\u003c/h1\u003e\n    \u003c/solid:fragment\u003e\n  \u003c/Example\u003e\n);\n```\n\n### `$props`\n\n`$props` is a compile-time function that provides access to the component's props.\n\n```jsx\nconst props = $props();\n\nexport default \u003ch1\u003e{props.message}\u003c/h1\u003e;\n```\n\nFor Typescript, you can pass a type for the generic parameter:\n\n```tsx\ninterface Props {\n  message: string;\n}\n\nconst props = $props\u003cProps\u003e();\n\nexport default \u003ch1\u003e{props.message}\u003c/h1\u003e;\n```\n\n### `$view`\n\nFor TypeScript to infer SFCs correctly, you can `$view` on the render part of the code.\n\n```tsx\n// Message.solid.tsx\ninterface Props {\n  message: string;\n}\n\nconst props = $props\u003cProps\u003e();\n\nexport default $view\u003cProps\u003e(\u003ch1\u003e{props.message}\u003c/h1\u003e);\n\n// App.solid.tsx\nimport Message from './Message.solid';\n\nexport default \u003cMessage message=\"Hello World\" /\u003e\n```\n\n## Tooling\n\n### TypeScript\n\n```ts\n/// \u003creference types=\"babel-plugin-solid-sfc\" /\u003e\n```\n\n## License\n\nMIT © [lxsmnsyc](https://github.com/lxsmnsyc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLXSMNSYC%2Fsolid-sfc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLXSMNSYC%2Fsolid-sfc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLXSMNSYC%2Fsolid-sfc/lists"}