Skip to content

Commit

Permalink
feat: initial commit - Shopify Special Resource Picker with XState
Browse files Browse the repository at this point in the history
  • Loading branch information
djang0dev committed Dec 21, 2024
1 parent ec4bb26 commit 4b318e5
Show file tree
Hide file tree
Showing 38 changed files with 19,956 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: "Install pnpm"
uses: pnpm/action-setup@v4
with:
version: 9
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Special Resource Picker# special-shopify-resource-picker
# Shopify Special Resource Picker

A Polaris resource picker which can handle any resources, It's intended to explain the usage of Finite State Machines and the Actor Model using XState

[Video](https://github.com/user-attachments/assets/241cce6e-cf0d-4eda-8ac2-bbf647277e67)

You can check [the live demo](https://djang0dev.github.io/special-shopify-resource-picker/), don't forget to click on the inspector


## Logic

We use the [Actor Model](https://stately.ai/docs/actor-model) for responsibility delegation:

![Actor Model Logic](https://djang0.dev/wp-content/uploads/2024/12/demo-gif.gif)
167 changes: 167 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"maxSize": 2097152,
"ignore": [
"theme.d.ts",
"documentation/plugins",
"documentation/static",
"libs/graphql-codegen",
"libs/translations/src/i18n/**/*"
]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},

"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"enabled": true,
"jsxQuoteStyle": "double",
"arrowParentheses": "always",
"quoteStyle": "double",
"semicolons": "asNeeded",
"trailingCommas": "all",
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
"bracketSameLine": true,
"quoteProperties": "asNeeded",
"bracketSpacing": true,
"lineWidth": 100
}
},
"json": {
"formatter": {
"enabled": true
},
"parser": {
"allowComments": false,
"allowTrailingCommas": false
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"noAriaHiddenOnFocusable": "warn",
"noAutofocus": "warn",
"noBlankTarget": "error",
"noNoninteractiveElementToInteractiveRole": "warn",
"noNoninteractiveTabindex": "warn",
"noPositiveTabindex": "warn",
"noSvgWithoutTitle": "warn",
"useAltText": "warn",
"useButtonType": "warn",
"useHtmlLang": "warn",
"useIframeTitle": "warn",
"useKeyWithClickEvents": "warn",
"useKeyWithMouseEvents": "warn",
"useValidAnchor": "warn"
},
"nursery": {},
"complexity": {
"useRegexLiterals": "error",
"noExcessiveCognitiveComplexity": {
"options": {
"maxAllowedComplexity": 18
},
"level": "error"
},
"noBannedTypes": "warn",
"noExtraBooleanCast": "warn",
"noForEach": "off",
"noStaticOnlyClass": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noUselessFragments": "off",
"noUselessRename": "error",
"noUselessSwitchCase": "error",
"useArrowFunction": "error",
"useLiteralKeys": "warn",
"useOptionalChain": "error"
},
"correctness": {
"noUndeclaredVariables": "warn",
"noConstAssign": "error",
"noChildrenProp": "warn",
"noPrecisionLoss": "error",
"useIsNan": "error",
"noInnerDeclarations": "error",
"noUnusedVariables": "error",
"noUnusedImports": "error",
"noConstantCondition": "error",
"noEmptyPattern": "error",
"noSwitchDeclarations": "error",
"noUnreachable": "error",
"noUnsafeOptionalChaining": "error",
"useExhaustiveDependencies": "error",
"useHookAtTopLevel": "error"
},
"performance": {
"noAccumulatingSpread": "warn",
"noDelete": "warn"
},
"security": {
"noGlobalEval": "error",
"noDangerouslySetInnerHtmlWithChildren": "error",
"noDangerouslySetInnerHtml": "error"
},
"style": {
"useWhile": "warn",
"noVar": "error",
"useImportType": "off",
"noCommaOperator": "error",
"noNonNullAssertion": "warn",
"noParameterAssign": "warn",
"noUnusedTemplateLiteral": "warn",
"noUselessElse": "error",
"useConst": "error",
"useDefaultParameterLast": "warn",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"useTemplate": "error"
},
"suspicious": {
"noDuplicateCase": "error",
"useIsArray": "warn",
"noArrayIndexKey": "warn",
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noConfusingVoidType": "warn",
"noControlCharactersInRegex": "error",
"noDoubleEquals": "error",
"noDuplicateJsxProps": "error",
"noDuplicateObjectKeys": "error",
"noEmptyInterface": "error",
"noExplicitAny": "warn",
"noFallthroughSwitchClause": "error",
"noGlobalIsNan": "error",
"noImplicitAnyLet": "warn",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noRedundantUseStrict": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "warn",
"useDefaultSwitchClauseLast": "error",
"useValidTypeof": "error"
}
}
},
"vcs": {
"clientKind": "git",
"defaultBranch": "main",
"enabled": true,
"useIgnoreFile": true
}
}
5 changes: 5 additions & 0 deletions graphql.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
projects:
main:
schema: "./schema-storefront.graphql"
documents: "./src/**/*.{tsx,ts}"
exclude: ["**/node_modules/**"]
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Special Shopify Resource Picker</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "demo-agnostic-resource-picker-xstate",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"graphql-request": "7.1.2",
"@shopify/polaris-icons": "9.3.0",
"remeda": "2.17.4",
"@shopify/polaris": "13.9.1",
"@xstate/react": "4.1.3",
"mutative": "1.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "2.4.1",
"react-infinite-scroll-hook": "5.0.1",
"xstate": "5.18.2",
"zod": "3.23.8",
"flat": "6.0.1",
"set-value": "4.1.0",
"@statelyai/inspect": "0.4.0"
},
"devDependencies": {
"@types/set-value": "4.0.3",
"@biomejs/biome": "1.9.4",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"globals": "^15.12.0",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.16",
"typescript": "~5.6.2",
"vite": "^6.0.1"
}
}
Loading

0 comments on commit 4b318e5

Please sign in to comment.