{"id":14990323,"url":"https://github.com/oakstudios/mechanical-ragger","last_synced_at":"2026-02-28T22:31:45.118Z","repository":{"id":40254465,"uuid":"296164927","full_name":"oakstudios/mechanical-ragger","owner":"oakstudios","description":"Mechanical text ragging for the web","archived":false,"fork":false,"pushed_at":"2022-05-17T22:11:58.000Z","size":62327,"stargazers_count":51,"open_issues_count":8,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-24T19:43:51.199Z","etag":null,"topics":["react","typesetting","typography","web-component"],"latest_commit_sha":null,"homepage":"https://oakstudios.github.io/mechanical-ragger/#essay","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/oakstudios.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-16T22:56:04.000Z","updated_at":"2025-06-17T15:51:29.000Z","dependencies_parsed_at":"2022-09-12T16:05:48.080Z","dependency_job_id":null,"html_url":"https://github.com/oakstudios/mechanical-ragger","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/oakstudios/mechanical-ragger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakstudios%2Fmechanical-ragger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakstudios%2Fmechanical-ragger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakstudios%2Fmechanical-ragger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakstudios%2Fmechanical-ragger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oakstudios","download_url":"https://codeload.github.com/oakstudios/mechanical-ragger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakstudios%2Fmechanical-ragger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29953284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T18:42:55.706Z","status":"ssl_error","status_checked_at":"2026-02-28T18:42:48.811Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["react","typesetting","typography","web-component"],"created_at":"2024-09-24T14:19:53.585Z","updated_at":"2026-02-28T22:31:45.069Z","avatar_url":"https://github.com/oakstudios.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mechanical Ragger\n\n**[Demo](https://oakstudios.github.io/mechanical-ragger/#essay)**\n\n## Installation\n\n```\nnpm i @oakstudios/mechanical-ragger\n```\n\n### Web Component\n\n1. Load the web component. Choose the option that best suits your needs:\n    \n    Using a `script` tag placed at the end of the `body`:\n    \n    ```html\n    \u003c!-- this automatically registers the component in the window as mechanical-ragger --\u003e\n    \u003cscript src=\"https://unpkg.com/@oakstudios/mechanical-ragger@0.4.1/web-component-auto-register.js\"\u003e\u003c/script\u003e\n    ```\n    \n    _OR_ importing the same auto-register function in JS:\n    \n    ```js\n    import \"@oakstudios/mechanical-ragger/web-component-auto-register\";\n    ```\n    \n    _OR_ registering the component manually:\n    \n    ```js\n    import MechanicalRagger from \"@oakstudios/mechanical-ragger/web-component\";\n    \n    customElements.define(\"mechanical-ragger\", MechanicalRagger);\n    ```\n\n2. Then add it to your HTML:\n\n   ```html\n   \u003cmechanical-ragger\u003e\n     Lorem ipsum dolor sit amet consectetur adipisicing elit.\n   \u003c/mechanical-ragger\u003e\n   ```\n\n### React Component\n\n```jsx\nimport MechanicalRagger from \"@oakstudios/mechanical-ragger/react\";\n\nexport default () =\u003e {\n  return \u003cMechanicalRagger\u003eLorem ipsum dolor sit amet.\u003c/MechanicalRagger\u003e;\n};\n```\n\n### Other Frameworks\n\nWhile web components can be used in most any framework, if you'd like deep integration with the framework of your choosing, you can use [`src/web-component.js`](src/web-component.js) and [`src/react.jsx`](src/react.jsx) to reference in implementing `mechanical-ragger` elsewhere.\n\nThe npm package also exposes the `MechanicalRaggerCore` module that these use. eg:\n\n```js\nimport MechanicalRaggerCore from \"@oakstudios/mechanical-ragger/core\";\n```\n\n## Options\n\n### `--ragging-width`\n\n`mechanical-ragger` inherits the depth of the mechanical ragging from a CSS custom property. To set this to a value other than the default, apply the custom property anywhere in the DOM containing the `mechanical-ragger`.\n\n```css\n/* Globally... */\nbody {\n  --ragging-width: 3rem;\n}\n\n/* Or Locally */\nmechanical-ragger:nth-child(1) {\n  --ragging-width: 4rem;\n}\nmechanical-ragger:nth-child(2) {\n  --ragging-width: 2rem;\n}\n```\n\nBecause this is a CSS custom property, you can change this value in the same place that you set the rest of your styles. The value will also respect other runtime conditions like media queries and application state.\n\n```css\nmechanical-ragger {\n  --ragging-width: 2rem;\n}\n/* Media Queries */\n@media (min-width: 480px) {\n  mechanical-ragger {\n    --ragging-width: 3rem;\n  }\n}\n/* User Preferences */\nbody.no-ragging mechanical-ragger {\n  --ragging-width: 0px;\n}\n```\n\nYou can also use any css unit (`ch`, `em`, `rem`, `vw`, etc)\n\n## Best Practices\n\n### ℹ️ Tidying line-ends\n\nYou may hope for text lines to reach closer to the end of each line to make the ragging cleaner. HTML and CSS both offer tools to manage this.\n\nIn CSS:\n\n```css\nmechanical-ragger {\n  /* Insert hyphens according to browser hyphenation dictionaries */\n  hyphens: auto;\n\n  /* Or only inserts hyphens at the author's request */\n  hyphens: manual;\n}\n```\n\n[With `hyphens: manual`, use the `\u0026shy;` HTML entity](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens#suggesting_line_break_opportunities) in your text to suggest hyphenation breakpoints to the browser.\n\nIn HTML, [the `\u003cwbr\u003e` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr) can be used to suggest a word breakpoint _without_ hyphenation.\n\n### ⚠️ Browser handling of line-heights.\n\nChrome and other browsers do not allow for floating-point decimal line-heights. All line-heights are rounded to the nearest CSS pixel (px values that do not factor in screen pixel-density). To ensure that the ragging does not fall out of sync with the text it controls, opt for line-heights that evaluate to whole pixels.\n\n## Development\n\n### Package\n\n`npm run build` in the root directory. The resulting modules are generated from the `src/` directory, to the root directory. This is the structure used in the npm package.\n\n### Docs\n\n`cd` into the `docs/` directory, where you can interact with the `create-react-app` instance.\n\n```\ncd docs\n\nnpm run start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foakstudios%2Fmechanical-ragger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foakstudios%2Fmechanical-ragger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foakstudios%2Fmechanical-ragger/lists"}