{"id":21606264,"url":"https://github.com/zaydek/lib","last_synced_at":"2025-03-18T14:43:50.843Z","repository":{"id":56584961,"uuid":"308530933","full_name":"zaydek/lib","owner":"zaydek","description":"Typed personal standard library","archived":false,"fork":false,"pushed_at":"2020-11-20T02:53:00.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-24T19:17:25.917Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaydek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-30T05:09:34.000Z","updated_at":"2020-11-20T02:50:16.000Z","dependencies_parsed_at":"2022-08-15T21:30:40.269Z","dependency_job_id":null,"html_url":"https://github.com/zaydek/lib","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Flib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Flib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Flib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Flib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaydek","download_url":"https://codeload.github.com/zaydek/lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244244472,"owners_count":20422300,"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-11-24T20:20:05.522Z","updated_at":"2025-03-18T14:43:50.819Z","avatar_url":"https://github.com/zaydek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @zaydek/lib\n\n`@zaydek/lib` is a typed standard library for personal use. Contributions and improvements are welcome as issues and or\npull requests.\n\nTo get started, simply run this command:\n\n```bash\nyarn add @zaydek/lib\n# or npm i @zaydek/lib\n```\n\n## Table of Contents\n\n- [`attrs/disableAutoCorrect`](#disableAutoCorrect)\n- [`attrs/target_blank`](#target_blank)\n- [`components/DocumentTitle`](#DocumentTitle)\n- [`components/LayoutDocumentTitle`](#LayoutDocumentTitle)\n- [`components/ExtAnchor`](#ExtAnchor)\n- [`components/Switch`](#Switch)\n- [`components/SVG`](#SVG)\n- [`components/Case`](#Case)\n- [`helpers/range`](#range)\n- [`helpers/toKebabCase`](#toKebabCase)\n- [`helpers/toTitleCase`](#toTitleCase)\n- [`hooks/useBreakpoints`](#useBreakpoints)\n\n---\n\n\u003ca id=\"disableAutoCorrect\" href=\"#disableAutoCorrect\"\u003e`attrs/disableAutoCorrect`\u003c/a\u003e\u003cbr\u003e\n\nAttributes for disabling autocorrect.\n\nRead https://davidwalsh.name/disable-autocorrect for more information.\n\n**Usage:**\n\n\u003c!-- prettier-ignore --\u003e\n```tsx\nimport { disableAutoCorrect } from \"@zaydek/lib/dist/attrs\"\n\n\u003cinput type=\"text\" {...disableAutoCorrect} /\u003e\n```\n\n---\n\n\u003ca id=\"target_blank\" href=\"#target_blank\"\u003e`attrs/target_blank`\u003c/a\u003e\n\nAttributes for safely opening an anchor in a separate page.\n\nRead https://mathiasbynens.github.io/rel-noopener for more information.\n\n**Usage:**\n\n\u003c!-- prettier-ignore --\u003e\n```tsx\nimport { target_blank } from \"@zaydek/lib/dist/attrs\"\n\n\u003ca href=\"...\" {...target_blank} /\u003e\n```\n\n---\n\n\u003ca id=\"DocumentTitle\" href=\"#DocumentTitle\"\u003e`components/DocumentTitle`\u003c/a\u003e\u003cbr\u003e\n\u003ca id=\"LayoutDocumentTitle\" href=\"#LayoutDocumentTitle\"\u003e`components/LayoutDocumentTitle`\u003c/a\u003e\n\n```ts\ninterface Props {\n\ttitle: string\n\tchildren?: React.ReactNode\n}\n```\n\nThe `DocumentTitle` components declaratively render `document.title`. They can be used as wrapper components or as\nside-effects.\n\nThe difference between `DocumentTitle` and `LayoutDocumentTitle` is simply whether `useEffect` or `useLayoutEffect` is\nused. `useLayoutEffect` renders _eagerly_ whereas `useEffect` renders _lazily_. If you don’t know what that means, use\n`DocumentTitle`.\n\n**Usage:**\n\n\u003c!-- prettier-ignore --\u003e\n```tsx\nimport { DocumentTitle } from \"@zaydek/lib/dist/components\"\n\n\u003cDocumentTitle title=\"...\"\u003e\n\t{children}\n\u003c/DocumentTitle\u003e\n```\n\n\u003c!-- prettier-ignore --\u003e\n```tsx\nimport { DocumentTitle } from \"@zaydek/lib/dist/components\"\n\n\u003cDocumentTitle title=\"...\" /\u003e\n```\n\n---\n\n\u003ca id=\"ExtAnchor\" href=\"#ExtAnchor\"\u003e`components/ExtAnchor`\u003c/a\u003e\u003cbr\u003e\n\nAn `\u003cExtAnchor\u003e` is simply an `\u003ca\u003e` with `target_blank` destructured.\n\n\u003c!-- prettier-ignore --\u003e\n```tsx\nimport { ExtAnchor } from \"@zaydek/lib/dist/components\"\n\n\u003cExtAnchor href=\"TODO\"\u003eHello, world!\u003c/ExtAnchor\u003e\n// -\u003e \u003ca href=\"TODO\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eHello, world!\u003c/a\u003e\n```\n\n---\n\n\u003c!-- prettier-ignore --\u003e\n\u003ca id=\"Switch\" href=\"#Switch\"\u003e`components/Switch`\u003c/a\u003e\u003cbr\u003e\n\u003ca id=\"Case\" href=\"#Case\"\u003e`components/Case`\u003c/a\u003e\u003cbr\u003e\n\nRenders a switch-case expression using JSX. `\u003cDefault\u003e` is not currently supported.\n\n**Usage:**\n\n```tsx\nimport { Switch, Case } from \"@zaydek/lib/dist/components\"\n\n\u003cSwitch on={...}\u003e\n  \u003cCase case={...}\u003e\n    ...\n  \u003cCase\u003e\n  \u003cCase case={...}\u003e\n    ...\n  \u003cCase\u003e\n  \u003cCase case={...}\u003e\n    ...\n  \u003cCase\u003e\n\u003c/Switch\u003e\n```\n\n**Note:** `\u003cSwitch\u003e` and `\u003cCase\u003e` are implemented using generics. This means you can use `\u003cSwitch\u003cstring\u003e\u003e` to enforce\ntype-correctness for `on={...}` or `\u003cCase\u003cstring\u003e\u003e` for `case={...}`. Note that `\u003cSwitch\u003cstring\u003e\u003e` **does not** enforce\ntype-correctness for children `\u003cCase\u003e` elements.\n\n---\n\n\u003ca id=\"range\" href=\"#range\"\u003e`helpers/range`\u003c/a\u003e\u003cbr\u003e\n\nHelper to declaratively generate a range. A range is simply an array of numbers, generally integers.\n\n```ts\nimport { range } from \"@zaydek/lib/dist/helpers\"\n\n// function range(to: number): number[]\nrange(1) // -\u003e [0]\nrange(2) // -\u003e [0, 1]\nrange(4) // -\u003e [0, 1, 2, 3]\nrange(8) // -\u003e [0, 1, 2, 3, 4, 5, 6, 7]\n```\n\n```ts\nimport { range } from \"@zaydek/lib/dist/helpers\"\n\n// function range(from: number, to: number): number[]\nrange(4, 8) // -\u003e [4, 5, 6, 7]\n```\n\n```ts\nimport { range } from \"@zaydek/lib/dist/helpers\"\n\n// function range(from: number, to: number, step: number): number[]\nrange(4, 8, 2) // -\u003e [4, 6]\n```\n\n---\n\n\u003ca id=\"toKebabCase\" href=\"#toKebabCase\"\u003e`helpers/toKebabCase`\u003c/a\u003e\u003cbr\u003e\n\u003ca id=\"toTitleCase\" href=\"#toTitleCase\"\u003e`helpers/toTitleCase`\u003c/a\u003e\u003cbr\u003e\n\nHelpers for converting between `kebab-case` and `TitleCase`.\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nimport { toKebabCase, toTitleCase } from \"@zaydek/lib/dist/helpers\"\n\ntoKebabCase(\"HelloWorld\")  // \"hello-world\"\ntoTitleCase(\"hello-world\") // \"HelloWorld\"\n```\n\n---\n\n\u003ca id=\"useBreakpoints\" href=\"#useBreakpoints\"\u003e`hooks/useBreakpoints`\u003c/a\u003e\u003cbr\u003e\n\nHook for conditionally rendering. The following breakpoints are used by default:\n\n```ts\nconst defaultBreakpoints = {\n\txs: 40 * 16, // -\u003e  512\n\tsm: 48 * 16, // -\u003e  640\n\tmd: 56 * 16, // -\u003e  768\n\tlg: 64 * 16, // -\u003e 1024\n\txl: 80 * 16, // -\u003e 1280\n}\n```\n\n`useBreakpoints` simulates `@media (min-width: ...)`. This API is preferred over `className=\"hidden sm:block\"`.\n\nYou can parameterize breakpoints by passing a `Breakpoints` object. Note that only `xs-xl` breakpoints are supported.\n\n**Usage:**\n\n```tsx\nimport { useBreakpoints } from \"@zaydek/lib/dist/hooks\"\n\nfunction Component() {\n\tconst screen = useBreakpoints()\n\treturn (\n\t\tscreen.sm \u0026\u0026 ( // @media (min-width: 768px) { ... }\n\t\t\t...\n\t\t)\n\t)\n}\n```\n\n## License\n\nLicensed as [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaydek%2Flib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaydek%2Flib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaydek%2Flib/lists"}