diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index acc4991..455b19f 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -49,23 +49,29 @@ const __dirname = path.dirname(__filename) export default defineConfig({ site: siteConfig.url, trailingSlash: 'never', - integrations: [mdx(), angular(), tailwind({ - applyBaseStyles: false, - }), sitemap({ - serialize(item) { - if (item.url === siteConfig.url) { - item.changefreq = 'daily' - item.lastmod = new Date() - item.priority = 1 - } - else { - item.changefreq = 'daily' - item.lastmod = new Date() - item.priority = 0.9 - } - return item - }, - }), alpinejs()], + integrations: [ + mdx(), + angular(), + tailwind({ + applyBaseStyles: false, + }), + sitemap({ + serialize(item) { + if (item.url === siteConfig.url) { + item.changefreq = 'daily' + item.lastmod = new Date() + item.priority = 1 + } + else { + item.changefreq = 'daily' + item.lastmod = new Date() + item.priority = 0.9 + } + return item + }, + }), + alpinejs({ entrypoint: '/src/entrypoints/alpine' }), + ], markdown: { syntaxHighlight: false, remarkPlugins: [codeImport], diff --git a/docs/package.json b/docs/package.json index a29c3a4..fa71cd2 100644 --- a/docs/package.json +++ b/docs/package.json @@ -11,6 +11,7 @@ "astro": "astro" }, "dependencies": { + "@alpinejs/focus": "^3.14.3", "@analogjs/astro-angular": "^1.9.0", "@angular/animations": "^18.2.9", "@angular/cdk": "^18.2.10", @@ -57,6 +58,7 @@ "@angular/platform-browser-dynamic": "^18.2.9", "@angular/platform-server": "^18.2.9", "@shikijs/transformers": "^1.20.0", + "@types/alpinejs__focus": "^3.13.4", "@types/lodash.template": "^4.5.3", "lodash.template": "^4.5.0", "mdast-util-toc": "^7.1.0", diff --git a/docs/src/components/CommandMenu.astro b/docs/src/components/CommandMenu.astro new file mode 100644 index 0000000..52542a5 --- /dev/null +++ b/docs/src/components/CommandMenu.astro @@ -0,0 +1,287 @@ +--- +import { cn } from '@/lib/utils' +import { buttonVariants } from '@/registry/new-york/ui/button' + +import { docsConfig } from '@/config/docs' + +let commandItems = docsConfig.sidebarNav.reduce( + ( + acc: { [key: string]: { title: string; value: string; icon: string; default: boolean; action: string }[] }, + section, + ) => { + acc[section.title] = section.items.map((item) => ({ + title: item.title, + value: item.title, + icon: ``, + default: true, + action: `window.location.href = '${item.href}'`, + })) + return acc + }, + { + links: docsConfig.mainNav.map((item) => ({ + title: item.title, + value: item.title, + icon: ``, + default: true, + action: `window.location.href = '${item.href}'`, + })), + }, +) + +commandItems = { + ...commandItems, + Theme: [ + { + title: 'Light', + icon: ``, + default: true, + value: 'Light', + action: `document.documentElement.classList.remove('dark')`, + }, + { + title: 'Dark', + icon: ``, + default: true, + value: 'Dark', + action: `document.documentElement.classList.add('dark')`, + }, + { + title: 'System', + icon: ``, + value: 'System', + action: `document.documentElement.classList.remove('dark'); window.matchMedia('(prefers-color-scheme: dark)').matches ? document.documentElement.classList.add('dark') : document.documentElement.classList.remove('dark')`, + default: true, + }, + ], +} +--- + +
+ + +
+ diff --git a/docs/src/components/Header.astro b/docs/src/components/Header.astro index a4eb507..455a2f7 100644 --- a/docs/src/components/Header.astro +++ b/docs/src/components/Header.astro @@ -4,6 +4,7 @@ import { buttonVariants } from '@/registry/new-york/ui/button' import Navbar from './Navbar.astro' import MobileNavbar from './MobileNavbar.astro' +import CommandMenu from './CommandMenu.astro' const { pathname } = Astro.url --- @@ -16,7 +17,7 @@ const { pathname } = Astro.url
- +
{ + Alpine.plugin(focus) +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a499445..33accce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -126,6 +126,9 @@ importers: docs: dependencies: + '@alpinejs/focus': + specifier: ^3.14.3 + version: 3.14.3 '@analogjs/astro-angular': specifier: ^1.9.0 version: 1.9.0(gic5oijsnuuyr6bfgpy7e3plve) @@ -259,6 +262,9 @@ importers: '@shikijs/transformers': specifier: ^1.20.0 version: 1.22.1 + '@types/alpinejs__focus': + specifier: ^3.13.4 + version: 3.13.4 '@types/lodash.template': specifier: ^4.5.3 version: 4.5.3 @@ -281,6 +287,9 @@ packages: resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} + '@alpinejs/focus@3.14.3': + resolution: {integrity: sha512-ZBL6HziMXhQIuta3PQjpYaMb5Ro9VPqh0mkP+d1uefJnhliBMWUfQXOnobV/0zJUB9pDxzd78diDX3ywewoJ3g==} + '@ampproject/remapping@2.3.0': resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} @@ -2497,6 +2506,9 @@ packages: '@types/alpinejs@3.13.10': resolution: {integrity: sha512-ah53tF6mWuuwerpDE7EHwbZErNDJQlsLISPqJhYj2RZ9nuTYbRknSkqebUd3igkhLIZKkPa7IiXjSn9qsU9O2w==} + '@types/alpinejs__focus@3.13.4': + resolution: {integrity: sha512-g7pQNxST7palODhfg6DJoKWS59pD8EK1wNjkJydBP2u8LntlO8oD4f2uj6Ywh2CL/olM/bPSyYxwr+WQQPlphg==} + '@types/babel__core@7.20.5': resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} @@ -4206,6 +4218,9 @@ packages: resolution: {integrity: sha512-9UbaD6XdAL97+k/n+N7JwX46K/M6Zc6KcFYskrYL8wbBV/Uyk0CTAMY0VT+qiK5PM7AIc9aTWYtq65U7T+aCNQ==} engines: {node: '>=8'} + focus-trap@6.9.4: + resolution: {integrity: sha512-v2NTsZe2FF59Y+sDykKY+XjqZ0cPfhq/hikWVL88BqLivnNiEffAsac6rP6H45ff9wG9LL5ToiDqrLEP9GX9mw==} + follow-redirects@1.15.9: resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} engines: {node: '>=4.0'} @@ -6866,6 +6881,9 @@ packages: resolution: {integrity: sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==} engines: {node: ^14.18.0 || >=16.0.0} + tabbable@5.3.3: + resolution: {integrity: sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA==} + tailwind-merge@2.5.2: resolution: {integrity: sha512-kjEBm+pvD+6eAwzJL2Bi+02/9LFLal1Gs61+QB7HvTfQQ0aXwC5LGT8PEt1gS0CWKktKe6ysPTAy3cBC5MeiIg==} @@ -7701,6 +7719,11 @@ snapshots: '@alloc/quick-lru@5.2.0': {} + '@alpinejs/focus@3.14.3': + dependencies: + focus-trap: 6.9.4 + tabbable: 5.3.3 + '@ampproject/remapping@2.3.0': dependencies: '@jridgewell/gen-mapping': 0.3.5 @@ -10147,6 +10170,10 @@ snapshots: '@types/alpinejs@3.13.10': {} + '@types/alpinejs__focus@3.13.4': + dependencies: + '@types/alpinejs': 3.13.10 + '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.26.2 @@ -12366,6 +12393,10 @@ snapshots: flattie@1.1.1: {} + focus-trap@6.9.4: + dependencies: + tabbable: 5.3.3 + follow-redirects@1.15.9(debug@4.3.7): optionalDependencies: debug: 4.3.7 @@ -15630,6 +15661,8 @@ snapshots: '@pkgr/core': 0.1.1 tslib: 2.8.0 + tabbable@5.3.3: {} + tailwind-merge@2.5.2: {} tailwindcss-animate@1.0.7(tailwindcss@3.4.13):