diff --git a/gallery/.gitignore b/gallery/.gitignore deleted file mode 100644 index d94aa3cc..00000000 --- a/gallery/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/src/examples -/node_modules -/dist diff --git a/gallery/package.json b/gallery/package.json deleted file mode 100644 index 77688dc1..00000000 --- a/gallery/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@moai/gallery", - "version": "1.3.0", - "description": "Widget Gallery of Moai 🗿", - "main": "dist/cjs.js", - "module": "dist/esm.js", - "types": "dist/types/index.d.ts", - "sideEffects": false, - "files": [ - "dist" - ], - "scripts": { - "_build": "rollup --config", - "_start": "rollup --config --watch", - "example": "ts-node ./scripts/example/generate.ts", - "prepublishOnly": "yarn _build" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/moaijs/moai.git" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/moaijs/moai/issues" - }, - "homepage": "https://moai.thien.do", - "email": "moai@thien.do", - "dependencies": { - "@moai/core": "*" - }, - "peerDependencies": { - "react": ">=16", - "react-icons": ">=4" - }, - "devDependencies": { - "@types/node": "^16.4.8", - "@types/react": "^17.0.15", - "node-fetch": "^2.6.1", - "postcss": "^8.3.6", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "react-icons": "^4.2.0", - "rollup": "^2.55.1", - "rollup-plugin-copy": "^3.4.0", - "rollup-plugin-delete": "^2.0.0", - "rollup-plugin-postcss": "^4.0.0", - "rollup-plugin-typescript2": "^0.30.0", - "ts-node": "^10.1.0", - "tslib": "^2.3.0", - "typescript": "^4.3.4" - } -} diff --git a/gallery/rollup.config.js b/gallery/rollup.config.js deleted file mode 100644 index dc9f2876..00000000 --- a/gallery/rollup.config.js +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-env node */ - -import del from "rollup-plugin-delete"; -import postcss from "rollup-plugin-postcss"; -import typescript2 from "rollup-plugin-typescript2"; - -/** - * Main bundling process - * @type {import("rollup").RollupOptions} - */ -const config = { - input: "src/index.tsx", - output: [ - { file: "dist/esm.js", format: "esm" }, - { file: "dist/cjs.js", format: "cjs" }, - ], - external: [ - "@moai/core", - "react", - "react/jsx-runtime", - // Because we have a demo where we show all icon from all sets :)). We - // could simplify this as a function, but it's just simpler to leave - // it all here (and better in term of performance) - "react-icons/ai", - "react-icons/bi", - "react-icons/cg", - "react-icons/fa", - "react-icons/fc", - "react-icons/fi", - "react-icons/go", - "react-icons/hi", - "react-icons/im", - "react-icons/io5", - "react-icons/md", - "react-icons/ri", - "react-icons/ti", - "react-icons/vsc", - ], - plugins: [ - del({ - targets: ["dist"], - }), - postcss({ - minimize: false, - extract: "bundle.css", - }), - typescript2({ - useTsconfigDeclarationDir: true, - }), - ], -}; - -export default config; diff --git a/gallery/scripts/example/generate.ts b/gallery/scripts/example/generate.ts deleted file mode 100644 index 9f8585db..00000000 --- a/gallery/scripts/example/generate.ts +++ /dev/null @@ -1,68 +0,0 @@ -import fetch from "node-fetch"; -import * as fs from "fs/promises"; -import * as path from "path"; -import { RawPokemon, RawPokemonList } from "./raw"; -import { normalizePokemon } from "./normalize"; -import { Pokemon } from "./interface"; - -type PokemonType = Pokemon["types"][0]; - -const getTypes = (pokemons: Pokemon[]): PokemonType[] => { - const set = pokemons.reduce((set, pokemon) => { - pokemon.types.forEach((type) => { - if (set.has(type)) return; - set.add(type); - }); - return set; - }, new Set()); - return [...set]; -}; - -const printProgress = (progress: string) => { - process.stdout.clearLine(0); - process.stdout.cursorTo(0); - process.stdout.write(progress + "%"); -}; - -const main = async () => { - // Skip if already populated (remove this to manually force a re-fetch) - const distPath = path.resolve(__dirname, "../../src/examples"); - try { - await fs.access(distPath); - console.log("Examples found"); - return; - } catch (e) { - console.log("Examples not found, generating..."); - } - - // Fetch list of pokemons - const resp = await fetch("https://pokeapi.co/api/v2/pokemon?limit=100"); - const raw = (await resp.json()) as RawPokemonList; - - // Fetch each pokemon - const count = { value: 0 }; - const promises = raw.results.map(async (result) => { - const resp = await fetch(result.url); - const raw = (await resp.json()) as RawPokemon; - count.value++; - printProgress(count.value.toString()); - const pokemon = normalizePokemon(raw); - return pokemon; - }); - const pokemons = await Promise.all(promises); - const types = getTypes(pokemons); - - // Write the result - fs.mkdir(distPath); - fs.writeFile( - path.resolve(distPath, "pokemons.json"), - JSON.stringify(pokemons, null, 2) - ); - fs.writeFile( - path.resolve(distPath, "types.json"), - JSON.stringify(types, null, 2) - ); - return pokemons; -}; - -main(); diff --git a/gallery/scripts/example/interface.ts b/gallery/scripts/example/interface.ts deleted file mode 100644 index fe04abc7..00000000 --- a/gallery/scripts/example/interface.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface Pokemon { - id: number; - name: string; - image: { - static: string; - animated: string; - }; - weight: number; - height: number; - moves: string; - stats: { - name: string; - base: number; - }[]; - types: string[]; -} diff --git a/gallery/scripts/example/normalize.ts b/gallery/scripts/example/normalize.ts deleted file mode 100644 index e95d9e02..00000000 --- a/gallery/scripts/example/normalize.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Pokemon } from "./interface"; -import { RawPokemon } from "./raw"; - -const getBw = (raw: RawPokemon) => - raw.sprites.versions["generation-v"]["black-white"]; - -export const normalizePokemon = (raw: RawPokemon): Pokemon => ({ - height: raw.height, - id: raw.id, - image: { - static: getBw(raw).front_default, - animated: getBw(raw).animated.front_default, - }, - moves: raw.moves.map((move) => move.move.name).join(", "), - name: raw.name, - stats: raw.stats.map((stat) => ({ - base: stat.base_stat, - name: stat.stat.name, - })), - types: raw.types.map((type) => type.type.name), - weight: raw.weight, -}); diff --git a/gallery/scripts/example/raw.ts b/gallery/scripts/example/raw.ts deleted file mode 100644 index 25ef0bc3..00000000 --- a/gallery/scripts/example/raw.ts +++ /dev/null @@ -1,87 +0,0 @@ -interface Ability2 { - name: string; - url: string; -} - -interface Ability { - ability: Ability2; - is_hidden: boolean; - slot: number; -} - -interface Move2 { - name: string; - url: string; -} - -interface Move { - move: Move2; -} - -interface Animated { - front_default: string; -} - -interface BlackWhite { - animated: Animated; - front_default: string; -} - -interface GenerationV { - "black-white": BlackWhite; -} - -interface Versions { - "generation-v": GenerationV; -} - -interface Sprites { - front_default: string; - versions: Versions; -} - -interface Stat2 { - name: string; - url: string; -} - -interface Stat { - base_stat: number; - effort: number; - stat: Stat2; -} - -interface Type2 { - name: string; - url: string; -} - -interface Type { - slot: number; - type: Type2; -} - -export interface RawPokemon { - abilities: Ability[]; - base_experience: number; - height: number; - id: number; - moves: Move[]; - name: string; - sprites: Sprites; - stats: Stat[]; - types: Type[]; - weight: number; -} - -interface Result { - name: string; - url: string; -} - -export interface RawPokemonList { - count: number; - next: string; - previous: unknown; - results: Result[]; -} diff --git a/gallery/tsconfig.json b/gallery/tsconfig.json deleted file mode 100644 index 781e46fe..00000000 --- a/gallery/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "composite": true, - "declaration": true, - "declarationDir": "dist/types", - "rootDir": "src" - }, - "references": [{ "path": "../core" }], - "include": ["src/**/*"] -} diff --git a/gallery/src/button-1.tsx b/src/gallery/button-1.tsx similarity index 100% rename from gallery/src/button-1.tsx rename to src/gallery/button-1.tsx diff --git a/gallery/src/button-2.tsx b/src/gallery/button-2.tsx similarity index 100% rename from gallery/src/button-2.tsx rename to src/gallery/button-2.tsx diff --git a/gallery/src/checkbox.tsx b/src/gallery/checkbox.tsx similarity index 100% rename from gallery/src/checkbox.tsx rename to src/gallery/checkbox.tsx diff --git a/gallery/src/dialog.tsx b/src/gallery/dialog.tsx similarity index 100% rename from gallery/src/dialog.tsx rename to src/gallery/dialog.tsx diff --git a/gallery/src/gallery.tsx b/src/gallery/gallery.tsx similarity index 100% rename from gallery/src/gallery.tsx rename to src/gallery/gallery.tsx diff --git a/gallery/src/global.d.ts b/src/gallery/global.d.ts similarity index 100% rename from gallery/src/global.d.ts rename to src/gallery/global.d.ts diff --git a/gallery/src/icon/icon.module.css b/src/gallery/icon/icon.module.css similarity index 100% rename from gallery/src/icon/icon.module.css rename to src/gallery/icon/icon.module.css diff --git a/gallery/src/icon/icon.tsx b/src/gallery/icon/icon.tsx similarity index 100% rename from gallery/src/icon/icon.tsx rename to src/gallery/icon/icon.tsx diff --git a/gallery/src/index.tsx b/src/gallery/index.tsx similarity index 100% rename from gallery/src/index.tsx rename to src/gallery/index.tsx diff --git a/gallery/src/input-1.tsx b/src/gallery/input-1.tsx similarity index 100% rename from gallery/src/input-1.tsx rename to src/gallery/input-1.tsx diff --git a/gallery/src/input-2.tsx b/src/gallery/input-2.tsx similarity index 100% rename from gallery/src/input-2.tsx rename to src/gallery/input-2.tsx diff --git a/gallery/src/pagination.tsx b/src/gallery/pagination.tsx similarity index 100% rename from gallery/src/pagination.tsx rename to src/gallery/pagination.tsx diff --git a/gallery/src/pane.tsx b/src/gallery/pane.tsx similarity index 100% rename from gallery/src/pane.tsx rename to src/gallery/pane.tsx diff --git a/gallery/src/popover.tsx.backup b/src/gallery/popover.tsx.backup similarity index 100% rename from gallery/src/popover.tsx.backup rename to src/gallery/popover.tsx.backup diff --git a/gallery/src/progress.tsx b/src/gallery/progress.tsx similarity index 100% rename from gallery/src/progress.tsx rename to src/gallery/progress.tsx diff --git a/gallery/src/section/section.module.css b/src/gallery/section/section.module.css similarity index 100% rename from gallery/src/section/section.module.css rename to src/gallery/section/section.module.css diff --git a/gallery/src/section/section.tsx b/src/gallery/section/section.tsx similarity index 100% rename from gallery/src/section/section.tsx rename to src/gallery/section/section.tsx diff --git a/gallery/src/select.tsx b/src/gallery/select.tsx similarity index 100% rename from gallery/src/select.tsx rename to src/gallery/select.tsx diff --git a/gallery/src/shot/shot.module.css b/src/gallery/shot/shot.module.css similarity index 100% rename from gallery/src/shot/shot.module.css rename to src/gallery/shot/shot.module.css diff --git a/gallery/src/shot/shot.tsx b/src/gallery/shot/shot.tsx similarity index 100% rename from gallery/src/shot/shot.tsx rename to src/gallery/shot/shot.tsx diff --git a/gallery/src/styles.module.css b/src/gallery/styles.module.css similarity index 100% rename from gallery/src/styles.module.css rename to src/gallery/styles.module.css diff --git a/gallery/src/tab.tsx b/src/gallery/tab.tsx similarity index 100% rename from gallery/src/tab.tsx rename to src/gallery/tab.tsx diff --git a/gallery/src/table/robo-schema.json b/src/gallery/table/robo-schema.json similarity index 100% rename from gallery/src/table/robo-schema.json rename to src/gallery/table/robo-schema.json diff --git a/gallery/src/table/robots.ts b/src/gallery/table/robots.ts similarity index 100% rename from gallery/src/table/robots.ts rename to src/gallery/table/robots.ts diff --git a/gallery/src/table/table.module.css b/src/gallery/table/table.module.css similarity index 100% rename from gallery/src/table/table.module.css rename to src/gallery/table/table.module.css diff --git a/gallery/src/table/table.tsx b/src/gallery/table/table.tsx similarity index 100% rename from gallery/src/table/table.tsx rename to src/gallery/table/table.tsx diff --git a/gallery/src/tag.tsx b/src/gallery/tag.tsx similarity index 100% rename from gallery/src/tag.tsx rename to src/gallery/tag.tsx diff --git a/gallery/src/toast.tsx b/src/gallery/toast.tsx similarity index 100% rename from gallery/src/toast.tsx rename to src/gallery/toast.tsx diff --git a/gallery/src/tooltip.tsx b/src/gallery/tooltip.tsx similarity index 100% rename from gallery/src/tooltip.tsx rename to src/gallery/tooltip.tsx