Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Vite #24

Merged
merged 3 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19.4.0
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,35 @@ docker compose -f docker-compose.dev.yml up -d
## More information

- [Roadmap](https://github.com/users/MayMeow/projects/4)

## Development

Requirements

- Docker or Docker Desktop
- Lando
- PHP 8.1 and up
- Node
- Yarn

### For backend

```bash
lando start
lando composer install
lando php bin/cake.php migrations migrate
```

### For frontend

```bash
fnm install # to install node - optionally
yarn install
yarn build
```

Source codes for frontend are stored in `webroot_src`, currently only styles which is slightly modified picocss.

‼️ After successfull build you need to change css path in `templates/layout/default.php`. (not ideal but for now it is like it is).

Application build is located in `webroot/app`.
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"name": "meowblog",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"repository": "https://github.com/MayMeow/meowblog",
"author": "May <may@maymeow.com>",
"license": "MIT"
"license": "MIT",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"@picocss/pico": "^1.5.6",
"@vitejs/plugin-vue": "^4.0.0",
"sass": "^1.57.1",
"vite": "^4.0.0"
}
}
8 changes: 4 additions & 4 deletions templates/Articles/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* @var \MeowBlog\Model\Entity\Article $article
*/
?>
<div class="headings">
<h2><?= $article->title ?></h2>
<h3>at <?= $article->created ?> by <?= $article->user->email ?></h3>
</div>
<div id="article">
<h1><?= $article->title ?></h1>
<div id="article-info">
at <?= $article->created ?> by <?= $article->user->email ?>
</div>
<div>
<?= $this->Markdown->parse($article->body); ?>
</div>
Expand Down
15 changes: 11 additions & 4 deletions templates/Home/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
]); ?>
</li>
<li>
<?= $this->Html->link('Logout', [
'action' => 'Logout',
'controller' => 'Users',
'prefix' => false
<?= $this->Html->link('Tags', [
'action' => 'Index',
'controller' => 'Articles',
'prefix' => 'Admin'
]); ?>
</li>
<li>
<?= $this->Html->link('Users', [
'action' => 'Index',
'controller' => 'Articles',
'prefix' => 'Admin'
]); ?>
</li>
</ul>
Expand Down
5 changes: 3 additions & 2 deletions templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</title>
<?= $this->Html->meta('icon') ?>

<?= $this->Html->css(['pico.min']) ?>
<?= $this->Html->css(['/app/assets/index-4dfde9ce']) ?>

<?= $this->fetch('meta') ?>
<?= $this->fetch('css') ?>
Expand All @@ -42,7 +42,8 @@
<li>
<strong>
<?= $this->Html->link('Meowblog.app', url:'/') ?>
</strong>
</strong> <br />
<small>Simple blogging app made with PHP</small>
</li>
</ul>
<ul>
Expand Down
13 changes: 13 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base: '/',
root: 'webroot_src',
build: {
outDir: '../webroot/app',
emptyOutDir: true,
}
})
4 changes: 4 additions & 0 deletions webroot/app/assets/index-4dfde9ce.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions webroot/app/assets/index-96cfb7ee.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions webroot/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<script type="module" crossorigin src="/assets/index-96cfb7ee.js"></script>
<link rel="stylesheet" href="/assets/index-4dfde9ce.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
1 change: 1 addition & 0 deletions webroot/app/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions webroot_src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup>
import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
<HelloWorld msg="MeowBlog" />
</template>

<style scoped>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
6 changes: 6 additions & 0 deletions webroot_src/assets/scss/_theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Custom Purple version */

// Override default variables
$primary-500: #9c27b0;
$primary-600: #8e24aa;
$primary-700: #7b1fa2;
2 changes: 2 additions & 0 deletions webroot_src/assets/scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "theme";
@import "@picocss/pico/scss/pico.scss";
40 changes: 40 additions & 0 deletions webroot_src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup>
import { ref } from 'vue'

defineProps({
msg: String,
})

const count = ref(0)
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Install
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
in your IDE for a better DX
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
</style>
12 changes: 12 additions & 0 deletions webroot_src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/main.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions webroot_src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import './assets/scss/main.scss'
import App from './App.vue'

createApp(App).mount('#app')
1 change: 1 addition & 0 deletions webroot_src/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions webroot_src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

.card {
padding: 2em;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
Loading