Skip to content

Commit

Permalink
feat: setup linter
Browse files Browse the repository at this point in the history
  • Loading branch information
gsbenevides2 committed Oct 28, 2024
1 parent 4955f34 commit d5a5072
Show file tree
Hide file tree
Showing 50 changed files with 1,769 additions and 535 deletions.
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"ecmel.vscode-html-css",
"tobermory.es6-string-html",
"denoland.vscode-deno",
"bradlc.vscode-tailwindcss"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"deno.enable": true,
"editor.quickSuggestions": {
"strings": true
},
"editor.defaultFormatter": "denoland.vscode-deno",
"[json]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
30 changes: 25 additions & 5 deletions actions/minicart/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ interface CartFormData {

export interface CartSubmitActions<AC = unknown> {
addToCart?: (props: CartFormData, req: Request, ctx: AC) => Promise<Minicart>;
setQuantity?: (props: CartFormData, req: Request, ctx: AC) => Promise<Minicart>;
setQuantity?: (
props: CartFormData,
req: Request,
ctx: AC,
) => Promise<Minicart>;
setCoupon?: (props: CartFormData, req: Request, ctx: AC) => Promise<Minicart>;
setSellerCode?: (props: CartFormData, req: Request, ctx: AC) => Promise<Minicart>;
setShipping?: (props: CartFormData, req: Request, ctx: AC) => Promise<Minicart>;
setSellerCode?: (
props: CartFormData,
req: Request,
ctx: AC,
) => Promise<Minicart>;
setShipping?: (
props: CartFormData,
req: Request,
ctx: AC,
) => Promise<Minicart>;
}

const safeParse = (payload: string | null) => {
Expand Down Expand Up @@ -90,13 +102,21 @@ const formActionsToCartActions: Record<string, keyof CartSubmitActions> = {
"set-shipping": "setShipping",
};

async function action(_props: unknown, req: Request, ctx: AppContext): Promise<Minicart> {
async function action(
_props: unknown,
req: Request,
ctx: AppContext,
): Promise<Minicart> {
const platformActions = actions[usePlatform()] as CartSubmitActions;

const form = cartFrom((await req.formData()) as unknown as FormData);
const action = form.action as string | null;

const decoActionName = action === null ? "setQuantity" : action in formActionsToCartActions ? formActionsToCartActions[action] : "setQuantity";
const decoActionName = action === null
? "setQuantity"
: action in formActionsToCartActions
? formActionsToCartActions[action]
: "setQuantity";
const handler = platformActions[decoActionName];

if (!handler) {
Expand Down
19 changes: 16 additions & 3 deletions apps/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ export interface Props extends WebsiteProps {
platform: Platform;
theme?: Section;
}
export type Platform = "vtex" | "vnda" | "shopify" | "wake" | "linx" | "nuvemshop" | "custom";
export type Platform =
| "vtex"
| "vnda"
| "shopify"
| "wake"
| "linx"
| "nuvemshop"
| "custom";
export let _platform: Platform = "vtex";
export type App = ReturnType<typeof Site>;
// @ts-ignore somehow deno task check breaks, I have no idea why
Expand Down Expand Up @@ -51,12 +58,18 @@ let firstRun = true;
* @category Tool
* @logo https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/1/0ac02239-61e6-4289-8a36-e78c0975bcc8
*/
export default function Site({ ...state }: Props): A<Manifest, Props, [ReturnType<typeof commerce>]> {
export default function Site(
{ ...state }: Props,
): A<Manifest, Props, [ReturnType<typeof commerce>]> {
_platform = state.platform || "custom";
// Prevent console.logging twice
if (firstRun) {
firstRun = false;
console.info(` ${rgb24("Storefront", color("deco"))} | ${rgb24(_platform, color(_platform))} \n`);
console.info(
` ${rgb24("Storefront", color("deco"))} | ${
rgb24(_platform, color(_platform))
} \n`,
);
}
return {
state,
Expand Down
29 changes: 25 additions & 4 deletions components/Icons/IconChevronsDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@ interface Props {
strokeWidth?: number;
}

export function IconCheveronsDown({ className, strokeClassName, strokeWidth }: Props) {
export function IconCheveronsDown(
{ className, strokeClassName, strokeWidth }: Props,
) {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
<path d="M7 13L12 18L17 13" className={strokeClassName} stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" />
<path d="M7 6L12 11L17 6" className={strokeClassName} stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" />
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M7 13L12 18L17 13"
className={strokeClassName}
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M7 6L12 11L17 6"
className={strokeClassName}
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);
}
29 changes: 25 additions & 4 deletions components/Icons/IconChevronsUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@ interface Props {
strokeWidth?: number;
}

export function IconCheveronsUp({ className, strokeClassName, strokeWidth }: Props) {
export function IconCheveronsUp(
{ className, strokeClassName, strokeWidth }: Props,
) {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
<path d="M17 11L12 6L7 11" className={strokeClassName} stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" />
<path d="M17 18L12 13L7 18" className={strokeClassName} stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" />
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M17 11L12 6L7 11"
className={strokeClassName}
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M17 18L12 13L7 18"
className={strokeClassName}
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);
}
32 changes: 28 additions & 4 deletions components/Icons/IconMenuDrawerOpen.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
export function IconMenuDrawerOpen() {
return (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.5 10H17.5" className="stroke-primary" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M2.5 5H17.5" className="stroke-primary" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M2.5 15H17.5" className="stroke-primary" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<svg
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M2.5 10H17.5"
className="stroke-primary"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M2.5 5H17.5"
className="stroke-primary"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M2.5 15H17.5"
className="stroke-primary"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);
}
17 changes: 15 additions & 2 deletions components/Icons/IconMinus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ interface Props {
}
export function IconMinus({ className, strokeClassName, strokeWidth }: Props) {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
<path d="M5 12H19" className={strokeClassName} stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" />
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M5 12H19"
className={strokeClassName}
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);
}
25 changes: 22 additions & 3 deletions components/Icons/IconPlus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ interface Props {
}
export function IconPlus({ className, strokeClassName, strokeWidth }: Props) {
return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
<path d="M12 5V19" stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" className={strokeClassName} />
<path d="M5 12H19" stroke-width={strokeWidth ?? "2"} stroke-linecap="round" stroke-linejoin="round" className={strokeClassName} />
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
d="M12 5V19"
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
className={strokeClassName}
/>
<path
d="M5 12H19"
stroke-width={strokeWidth ?? "2"}
stroke-linecap="round"
stroke-linejoin="round"
className={strokeClassName}
/>
</svg>
);
}
25 changes: 22 additions & 3 deletions components/Icons/IconUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ interface Props {

export function IconUser({ className = "" }: Props) {
return (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" className={clx(className)}>
<path d="M16.6663 17.5V15.8333C16.6663 14.9493 16.3152 14.1014 15.69 13.4763C15.0649 12.8512 14.2171 12.5 13.333 12.5H6.66634C5.78229 12.5 4.93444 12.8512 4.30932 13.4763C3.6842 14.1014 3.33301 14.9493 3.33301 15.8333V17.5" className="stroke-primary" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M10.0003 9.16667C11.8413 9.16667 13.3337 7.67428 13.3337 5.83333C13.3337 3.99238 11.8413 2.5 10.0003 2.5C8.15938 2.5 6.66699 3.99238 6.66699 5.83333C6.66699 7.67428 8.15938 9.16667 10.0003 9.16667Z" className="stroke-primary" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<svg
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={clx(className)}
>
<path
d="M16.6663 17.5V15.8333C16.6663 14.9493 16.3152 14.1014 15.69 13.4763C15.0649 12.8512 14.2171 12.5 13.333 12.5H6.66634C5.78229 12.5 4.93444 12.8512 4.30932 13.4763C3.6842 14.1014 3.33301 14.9493 3.33301 15.8333V17.5"
className="stroke-primary"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M10.0003 9.16667C11.8413 9.16667 13.3337 7.67428 13.3337 5.83333C13.3337 3.99238 11.8413 2.5 10.0003 2.5C8.15938 2.5 6.66699 3.99238 6.66699 5.83333C6.66699 7.67428 8.15938 9.16667 10.0003 9.16667Z"
className="stroke-primary"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);
}
Loading

0 comments on commit d5a5072

Please sign in to comment.