{"id":22729815,"url":"https://github.com/gc-victor/c-c","last_synced_at":"2025-04-13T23:13:29.824Z","repository":{"id":42748295,"uuid":"270376889","full_name":"gc-victor/c-c","owner":"gc-victor","description":"CSS-in-JS atomic classes at run-time and compile-time","archived":false,"fork":false,"pushed_at":"2023-01-06T11:48:13.000Z","size":92,"stargazers_count":10,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T23:13:17.905Z","etag":null,"topics":["atomic-classes","atomic-css","css","css-in-js","functional-css","utility-classes"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/gc-victor.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-06-07T17:15:01.000Z","updated_at":"2024-09-02T06:15:59.000Z","dependencies_parsed_at":"2023-02-06T00:30:26.683Z","dependency_job_id":null,"html_url":"https://github.com/gc-victor/c-c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gc-victor%2Fc-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gc-victor%2Fc-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gc-victor%2Fc-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gc-victor%2Fc-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gc-victor","download_url":"https://codeload.github.com/gc-victor/c-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794569,"owners_count":21162615,"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":["atomic-classes","atomic-css","css","css-in-js","functional-css","utility-classes"],"created_at":"2024-12-10T18:11:52.836Z","updated_at":"2025-04-13T23:13:29.800Z","avatar_url":"https://github.com/gc-victor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# c-c\n\nTiny CSS-in-JS atomic classes at run-time and compile-time.\n\n## Let's Play\n\nCreate your first styles. Each declaration will return a class name and inject them to a stylesheet.\n\n```javascript\nc({\n    padding: '1rem', \n    marginTop: '1rem'\n});\n```\n\nReturns:\n```\nc4218071375 c3162900569\n```\n\nYou can use media queries.\n\n```javascript\nc({\n    '@media (min-width: 1px)': {\n        padding: '1rem',\n        margin: '1rem'\n    }\n});\n```\n\nEven classes, pseudo-classes, pseudo-elements, child combinator, adjacent sibling combinator and general sibling combinator.\n\n```javascript\nc({\n    '.class-name': {\n        padding: '1rem'\n    },\n    '\u003e p': {\n        ':hover': { padding: '1rem' }\n    },\n    '+ p': {\n        padding: '1rem'\n    },\n    '~ p': {\n        padding: '1rem'\n    },\n    ':hover': { padding: '1rem' },\n    '::after': { content: '\"»\"', color: 'red' },\n});\n```\n\nUsing `styles()` you will get all the styles for your Server Side Rendering (SSR) or Static Site Generation (SSG) projects.\n\nReturns:\n```css\n.c4218071375{padding:1rem}\n```\n\n## Compile time\n\nYou have to import the macro to use c-c at compile time.\n```javascript\nimport { c } from 'c-c/macro';\n```\n\nYou have to have installed [babeljs](https://babeljs.io/) and [babel-plugin-macros](https://github.com/kentcdodds/babel-plugin-macros) and add the last one\nto the babel plugins config.\n\nIt will generate a `styles.css` file in your current working directory.\n\nYour code will be transformed from:\n\n```javascript\nimport { c } from 'c-c/macro';\n\nconst css0 = c({ padding: 0, margin: 0 });\nconst css1 = c({ padding: '1rem' });\nconst css2 = c({ padding: '1rem' });\n```\n\nTo:\n\n```javascript\nconst css0 = \"c2343579090 c2342591469\";\nconst css1 = \"c4218071375\";\nconst css2 = \"c4218071375\";\n```\n\nAs you can see, the import is removed, and the classes names have replaced the function.\n\n## Extra ball\n\nThe [styles.js](https://github.com/gc-victor/c-c/blob/master/styles.js) file is a modified version of TailwindCSS config file to copy to your project and modify it to fit your needs.\n\n````javascript\nimport { color, fontSize, spacing } form './styles';\n\nc({\n    color: color.black,\n    fontSize: fontSize.xl,\n    margin: spacing.x4,\n    paddingTop: spacing.x10\n});\n````\n\n## Acknowledgments\n\n### Inspiration\n\n- [goober](https://github.com/cristianbote/goober) for the [hash generator](https://github.com/cristianbote/goober/blob/v1/src/core/to-hash.js#L10) and some other ideas\n- [object-style](https://github.com/jxnblk/object-style/) is library the main piece of c-c\n- [cxs](https://github.com/cxs-css/cxs) for ideas to optimize object-style parse, and the benchmark\n- [tailwindcss](https://github.com/tailwindcss/tailwindcss) for their [config file](https://github.com/tailwindcss/tailwindcss/blob/v1.4.6/stubs/defaultConfig.stub.js) that is used as a reference to create the [styles.js](https://github.com/gc-victor/c-c/blob/master/styles.js)\n\n## Compatible Versioning\n\n### Summary\n\nGiven a version number MAJOR.MINOR, increment the:\n\n- MAJOR version when you make backwards-incompatible updates of any kind\n- MINOR version when you make 100% backwards-compatible updates\n\nAdditional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR format.\n\n[![ComVer](https://img.shields.io/badge/ComVer-compliant-brightgreen.svg)](https://github.com/staltz/comver)\n\n## Contribute\n\nFirst off, thanks for taking the time to contribute!\nNow, take a moment to be sure your contributions make sense to everyone else.\n\n### Reporting Issues\n\nFound a problem? Want a new feature? First of all, see if your issue or idea has [already been reported](../../issues).\nIf it hasn't, just open a [new clear and descriptive issue](../../issues/new).\n\n### Commit message conventions\n\nA specification for adding human and machine readable meaning to commit messages.\n\n- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)\n\n### Submitting pull requests\n\nPull requests are the greatest contributions, so be sure they are focused in scope and do avoid unrelated commits.\n\n-   Fork it!\n-   Clone your fork: `git clone http://github.com/\u003cyour-username\u003e/c-c`\n-   Navigate to the newly cloned directory: `cd c-c`\n-   Create a new branch for the new feature: `git checkout -b my-new-feature`\n-   Install the tools necessary for development: `npm install`\n-   Make your changes.\n-   `npm run build` to verify your change doesn't increase output size.\n-   `npm test` to make sure your change doesn't break anything.\n-   Commit your changes: `git commit -am 'Add some feature'`\n-   Push to the branch: `git push origin my-new-feature`\n-   Submit a pull request with full remarks documenting your changes.\n\n## License\n\n[MIT License](https://github.com/gc-victor/c-c/blob/master/LICENSE)\n\nCopyright (c) 2020 Víctor García\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgc-victor%2Fc-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgc-victor%2Fc-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgc-victor%2Fc-c/lists"}