Skip to content

Commit

Permalink
Update templates for dist
Browse files Browse the repository at this point in the history
  • Loading branch information
blittle committed Jun 18, 2024
1 parent af573bc commit a55baaa
Show file tree
Hide file tree
Showing 134 changed files with 54,871 additions and 36 deletions.
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
12 changes: 12 additions & 0 deletions templates/skeleton-js/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @type {import("@types/eslint").Linter.BaseConfig}
*/
module.exports = {
extends: ['@remix-run/eslint-config', 'plugin:hydrogen/recommended'],
rules: {
'hydrogen/prefer-image-component': 'off',
'no-useless-escape': 'off',
'no-case-declarations': 'off',
'no-console': ['warn', {allow: ['warn', 'error']}],
},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
77 changes: 77 additions & 0 deletions templates/skeleton-js/app/components/Aside.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {createContext, useContext, useState} from 'react';

/**
* A side bar component with Overlay
* @example
* ```jsx
* <Aside type="search" heading="SEARCH">
* <input type="search" />
* ...
* </Aside>
* ```
* @param {{
* children?: React.ReactNode;
* type: AsideType;
* heading: React.ReactNode;
* }}
*/
export function Aside({children, heading, type}) {
const {type: activeType, close} = useAside();
const expanded = type === activeType;

return (
<div
aria-modal
className={`overlay ${expanded ? 'expanded' : ''}`}
role="dialog"
>
<button className="close-outside" onClick={close} />
<aside>
<header>
<h3>{heading}</h3>
<button className="close reset" onClick={close}>
&times;
</button>
</header>
<main>{children}</main>
</aside>
</div>
);
}

const AsideContext = createContext(null);

Aside.Provider = function AsideProvider({children}) {
const [type, setType] = useState('closed');

return (
<AsideContext.Provider
value={{
type,
open: setType,
close: () => setType('closed'),
}}
>
{children}
</AsideContext.Provider>
);
};

export function useAside() {
const aside = useContext(AsideContext);
if (!aside) {
throw new Error('useAside must be used within an AsideProvider');
}
return aside;
}

/** @typedef {'search' | 'cart' | 'mobile' | 'closed'} AsideType */
/**
* @typedef {{
* type: AsideType;
* open: (mode: AsideType) => void;
* close: () => void;
* }} AsideContextValue
*/

/** @typedef {import('react').ReactNode} ReactNode */
Loading

0 comments on commit a55baaa

Please sign in to comment.