Skip to content

Commit

Permalink
Merge pull request #70 from bywhitebird/46-initialize-alakazam
Browse files Browse the repository at this point in the history
46 initialize alakazam
  • Loading branch information
arthur-fontaine authored Nov 12, 2023
2 parents 68dda4f + 0fdf725 commit dceabcc
Show file tree
Hide file tree
Showing 25 changed files with 4,002 additions and 401 deletions.
15 changes: 15 additions & 0 deletions apps/alakazam/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: ['plugin:vue/vue3-recommended'],
parser: "vue-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
ecmaVersion: 2020,
ecmaFeatures: {
jsx: true
}
},
rules: {
'vue/multi-word-component-names': 'off',
},
}
28 changes: 28 additions & 0 deletions apps/alakazam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example

# Panda
styled-system
styled-system-static
1 change: 1 addition & 0 deletions apps/alakazam/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
63 changes: 63 additions & 0 deletions apps/alakazam/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Nuxt 3 Minimal Starter

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

## Setup

Make sure to install the dependencies:

```bash
# npm
npm install

# pnpm
pnpm install

# yarn
yarn install
```

## Development Server

Start the development server on `http://localhost:3000`:

```bash
# npm
npm run dev

# pnpm
pnpm run dev

# yarn
yarn dev
```

## Production

Build the application for production:

```bash
# npm
npm run build

# pnpm
pnpm run build

# yarn
yarn build
```

Locally preview production build:

```bash
# npm
npm run preview

# pnpm
pnpm run preview

# yarn
yarn preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
41 changes: 41 additions & 0 deletions apps/alakazam/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { createResolver } from '@nuxt/kit'

const { resolve } = createResolver(import.meta.url)

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },

srcDir: 'src',

modules: [
'nuxt-typed-router',
],

alias: {
'styled-system': resolve('./styled-system'),
},

css: [
'@/assets/css/global.css',
],

postcss: {
plugins: {
'@pandacss/dev/postcss': {},
},
},

imports: {
presets: [
{
from: '~/styled-system/css',
imports: ['css'],
},
],
},

build: {
transpile: ['fsevents'],
},
})
23 changes: 23 additions & 0 deletions apps/alakazam/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "alakazam",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"prepare": "panda codegen"
},
"dependencies": {
"@whitebird/ui": "workspace:*"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@pandacss/dev": "^0.14.0",
"eslint-plugin-vue": "^9.17.0",
"glob": "^10.3.4",
"nuxt": "^3.7.1",
"nuxt-typed-router": "^3.3.1"
}
}
21 changes: 21 additions & 0 deletions apps/alakazam/panda.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from '@pandacss/dev'
import { whitebirdPreset } from '@whitebird/ui/panda-preset'

export default defineConfig({
// Whether to use css reset
preflight: true,

// Where to look for your css declarations
include: ['./src/**/*.{js,jsx,ts,tsx,vue}'],

// Files to exclude
exclude: [],

presets: [whitebirdPreset],

// The output directory for your css system
outdir: './src/styled-system',

// Generate JSX components
jsxFramework: 'vue',
})
4 changes: 4 additions & 0 deletions apps/alakazam/src/assets/css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import '@whitebird/ui/css';
@import '@whitebird/ui/css/fonts';

@layer reset, base, tokens, recipes, utilities;
17 changes: 17 additions & 0 deletions apps/alakazam/src/features/welcome/components/welcome.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
const { data } = await useAsyncData(async () => 3)
</script>

<template>
<div :class="css({ fontSize: 'sm', fontWeight: 'bolder' })">
Hello 🐼! {{ data }}
</div>
<Box
margin="1"
bg="primary"
text-align="center"
font-size="md"
>
Bonjour 🐼!
</Box>
</template>
26 changes: 26 additions & 0 deletions apps/alakazam/src/features/welcome/pages/welcome.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
import Button from "@whitebird/ui/vue/button"
</script>

<template>
<div
:class="css({
bg: 'appBackground',
color: 'highContrastForeground',
height: '100dvh',
width: '100dvw',
})"
>
test
<Welcome />
<NuxtLink :to="{ name: 'welcome-page' }">
TEST 43
</NuxtLink>
<Button
text="THIS IS A BUTTON"
variant="secondary"
icon-name="square"
@click="() => console.log('BUTTON CLICKED')"
/>
</div>
</template>
9 changes: 9 additions & 0 deletions apps/alakazam/src/features/welcome/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineNuxtRoutes } from "~/shared/utils/define-nuxt-routes";

export default defineNuxtRoutes(__dirname, [
{
name: 'welcome-page',
path: '/',
file: './pages/welcome.vue',
},
])
25 changes: 25 additions & 0 deletions apps/alakazam/src/modules/panda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
addComponent, createResolver,
defineNuxtModule, resolveFiles,
} from '@nuxt/kit'

const { resolve } = createResolver(import.meta.url)

export default defineNuxtModule({
async setup() {
const componentsPath = resolve(__dirname, '../styled-system/jsx')

const componentFiles = await resolveFiles(__dirname, `${componentsPath}/*.mjs`)

for (const file of componentFiles) {
const componentName = file.split('/').pop()?.replace(/\.mjs$/, '')
const exportedComponentName = await import(/* @vite-ignore */ file).then(m => Object.keys(m)[0])

addComponent({
name: exportedComponentName,
export: exportedComponentName,
filePath: resolve(`${componentsPath}/${componentName}.mjs`),
})
}
},
})
37 changes: 37 additions & 0 deletions apps/alakazam/src/modules/register-features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
addComponentsDir, addImportsDir, defineNuxtModule, extendPages,
createResolver, loadNuxtConfig, resolveFiles,
} from '@nuxt/kit'
import type { NuxtPage } from '@nuxt/schema'
import jiti from 'jiti'

const { resolve } = createResolver(import.meta.url)

export default defineNuxtModule({
async setup() {
const getRoutes = jiti(__filename, {
alias: await loadNuxtConfig({}).then(c => c.alias),
})

const featurePaths = await resolveFiles(__dirname, '../features/**/routes.ts')

for (const file of featurePaths) {
const routes = getRoutes(file).default
defineNuxtFeature(resolve(file, '..'), routes)
}
},
})

function defineNuxtFeature(dirname: string, routes: NuxtPage[]) {
const { resolve } = createResolver(dirname)

addComponentsDir({
path: resolve('components'),
})

addImportsDir(resolve('./composables'))

extendPages((pages) => {
pages.push(...routes)
})
}
Binary file added apps/alakazam/src/public/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions apps/alakazam/src/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
16 changes: 16 additions & 0 deletions apps/alakazam/src/shared/utils/define-nuxt-routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createResolver } from '@nuxt/kit'

import type { NuxtPage } from 'nuxt/schema'

export const defineNuxtRoutes = (dirname: string, routes: {
name: string,
path: `/${string}`,
file: `./pages/${string}.vue`,
}[]): NuxtPage[] => {
const { resolve } = createResolver(dirname)

return routes.map(route => ({
...route,
file: resolve(dirname, route.file),
}))
}
4 changes: 4 additions & 0 deletions apps/alakazam/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}
Loading

0 comments on commit dceabcc

Please sign in to comment.