{"id":16184603,"url":"https://github.com/rmariuzzo/shorted-theme","last_synced_at":"2025-03-19T02:31:30.549Z","repository":{"id":57358756,"uuid":"296494623","full_name":"rmariuzzo/shorted-theme","owner":"rmariuzzo","description":"Shorted theme references for Styled Components.","archived":false,"fork":false,"pushed_at":"2020-09-23T16:11:06.000Z","size":546,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-24T15:45:41.457Z","etag":null,"topics":["styled","styled-components","theme","utility"],"latest_commit_sha":null,"homepage":"","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/rmariuzzo.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":"2020-09-18T02:38:10.000Z","updated_at":"2023-08-24T20:44:42.000Z","dependencies_parsed_at":"2022-09-06T22:21:47.869Z","dependency_job_id":null,"html_url":"https://github.com/rmariuzzo/shorted-theme","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fshorted-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fshorted-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fshorted-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fshorted-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmariuzzo","download_url":"https://codeload.github.com/rmariuzzo/shorted-theme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221720417,"owners_count":16869482,"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":["styled","styled-components","theme","utility"],"created_at":"2024-10-10T07:10:41.393Z","updated_at":"2024-10-27T19:09:06.804Z","avatar_url":"https://github.com/rmariuzzo.png","language":"TypeScript","readme":"# ![shorted-theme - Shorted theme references for Styled Components.](.github/assets/banner.svg)\n\n![Comparison: before and after](.github/assets/comparison.png)\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Features\n\n- Zero dependencies.\n- [TypeScript support](#typescript-support).\n- Write less characters.\n- Tests with 100% coverage.\n\n## Installation\n\n```bash\nnpm i shorted-theme\n```\n\n## Usage\n\n```ts\nimport styled from 'styled-components'\nimport shorted from 'shorted-theme'\n\nconst theme = {\n  colors: {\n    primary: 'red',\n    secondary: 'blue'\n  },\n  fontFamily: '\"Roboto\", sans-serif',\n  fontSizes: {\n    small: 12,\n    regular: 14,\n    large: 18\n  }\n}\n\nconst t = shorted(theme) // 👈 short your theme then use everywhere.\n\nconst Button = styled.button`\n  color: ${t.colors.primary};\n  color: ${t.colors.primary};\n  font-family: ${t.fontFamily};\n  font-size: ${t.fontSizes.regular};\n`\n```\n\n## TypeScript Support\n\n`shorted-theme` use all your typings.\n\n![](.github/assets/typescript-support.png)\n\n### Suggestion\n\nYou can destructure the shorted theme object. That way you can reference direct children properties instead of a root object.\n\n```ts\nconst { colors, fontFamily, fontSizes } = shorted(theme)\n\nconst Button = styled.button`\n  color: ${colors.primary};\n  color: ${colors.primary};\n  font-family: ${fontFamily};\n  font-size: ${fontSizes.regular};\n`\n```\n\n## Limitations\n\n`shorted-theme` is useful for writing less when referencing theme values. However, it can't be used in expressions. For example:\n\n```ts\n// THIS WILL NOT WORK\nconst Button = styled.button`\n  padding: ${t.padding.default * 10};\n`\n```\n\nInstead you should use the function expression:\n\n```ts\nconst Button = styled.button`\n  padding: ${(props) =\u003e props.theme.padding.default * 10};\n`\n```\n\n## Development\n\n1.  Clone this repository.\n2.  Install dependencies: `npm i`.\n3.  Run it locally: `npm start` or `./src/bin.js`\n\n### Tests\n\n```sh\nnpm run test\n```\n\n### Releases\n\nReleases are triggered by `npm version` and handled by [GitHub Actions](https://github.com/rmariuzzo/shorted-theme/actions?query=workflow%3Apublish).\n\n\u003ccenter\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\nMade with ♥ by \u003ca href=\"https://github.com/rmariuzzo\" target=\"_blank\"\u003e@rmariuzzo\u003c/a\u003e\n\u003c/center\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fshorted-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmariuzzo%2Fshorted-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fshorted-theme/lists"}