Skip to content

Commit 5488120

Browse files
committed
refactor
1 parent ad42d8e commit 5488120

File tree

85 files changed

+1869
-2223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1869
-2223
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ Different UI for [larave/jetstream](https://github.com/laravel/jetstream).
77
[![Stars](https://img.shields.io/github/stars/Kamona-WD/kui-laravel-jetstream)](https://github.com/Kamona-WD/kui-laravel-jetstream/stargazers)
88
[![Total Downloads](https://img.shields.io/packagist/dt/kamona/kui-laravel-jetstream.svg)](https://packagist.org/packages/kamona/kui-laravel-jetstream)
99

10-
#### [Figma file](https://www.figma.com/community/file/1019844542917981418/)
1110
#### [Breeze Version](https://github.com/Kamona-WD/kui-laravel-breeze)
12-
#### [Fortify Version](https://github.com/Kamona-WD/kui-laravel-fortify)
11+
<!-- #### [Fortify Version](https://github.com/Kamona-WD/kui-laravel-fortify) -->
1312

1413
#### Note
1514

src/Console/ReplaceCommand.php

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class ReplaceCommand extends Command
1414
* @var string
1515
*/
1616
protected $signature = 'kui-jetstream:replace {stack : The development stack that should be replaced (livewire,inertia)}
17-
{--composer=global : Absolute path to the Composer binary which should be used to install packages}';
17+
{--composer=global : Absolute path to the Composer binary which should be used to install packages}
18+
{--vite : Vitejs}';
1819

1920
/**
2021
* The console command description.
@@ -23,6 +24,8 @@ class ReplaceCommand extends Command
2324
*/
2425
protected $description = 'Replace laravel\\jetstream views.';
2526

27+
protected $isVite = false;
28+
2629
/**
2730
* Create a new command instance.
2831
*
@@ -40,6 +43,14 @@ public function __construct()
4043
*/
4144
public function handle()
4245
{
46+
$this->writeLogo();
47+
48+
$this->replaceFavIcon();
49+
50+
if (file_exists(base_path('vite.config.js')) || $this->option('vite')) {
51+
$this->isVite = true;
52+
}
53+
4354
if ($this->argument('stack') === 'inertia') {
4455
return $this->replaceInertia();
4556
}
@@ -53,24 +64,22 @@ public function replaceInertia()
5364
{
5465
// NPM Packages...
5566
$this->updateNodePackages(function ($packages) {
56-
return [
67+
$extraPackages = [
5768
'@heroicons/vue' => '^1.0.4',
58-
'@headlessui/vue' => '^1.4.1',
69+
'@headlessui/vue' => '^1.4.3',
5970
'@vueuse/core' => '^6.5.3',
60-
'@vue/babel-plugin-jsx' => '^1.1.0',
61-
'autoprefixer' => '^10.3.7',
62-
'postcss' => '^8.3.9',
63-
'tailwindcss' => '^3.0.7',
64-
'@tailwindcss/forms' => '^0.4.0',
65-
'@tailwindcss/typography' => '^0.5.0',
6671
'perfect-scrollbar' => '^1.5.2',
67-
'vue' => '^3.2.26',
6872
'vue-toastification' => '^2.0.0-rc.1'
6973
] + $packages;
70-
});
7174

72-
// Views...
73-
copy(__DIR__ . '/../../stubs/inertia/views/app.blade.php', resource_path('views/app.blade.php'));
75+
if (!$this->isVite) {
76+
$extraPackages += ['@vue/babel-plugin-jsx' => '^1.1.0'];
77+
} else {
78+
$extraPackages += ['@vitejs/plugin-vue-jsx' => '^1.3.10'];
79+
}
80+
81+
return $extraPackages + $packages;
82+
});
7483

7584
// Components + Pages...
7685
(new Filesystem)->ensureDirectoryExists(resource_path('js/Components'));
@@ -85,14 +94,23 @@ public function replaceInertia()
8594
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/inertia/js/Pages', resource_path('js/Pages'));
8695
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/inertia/js/Toast', resource_path('js/Toast'));
8796

88-
// Tailwind / Webpack...
97+
8998
copy(__DIR__ . '/../../stubs/inertia/tailwind.config.js', base_path('tailwind.config.js'));
9099
copy(__DIR__ . '/../../stubs/inertia/css/app.css', resource_path('css/app.css'));
91-
copy(__DIR__ . '/../../stubs/inertia/js/app.js', resource_path('js/app.js'));
92-
copy(__DIR__ . '/../../stubs/inertia/.babelrc', base_path('.babelrc'));
93-
copy(__DIR__ . '/../../stubs/inertia/webpack.config.js', base_path('webpack.config.js'));
94-
copy(__DIR__ . '/../../stubs/inertia/webpack.mix.js', base_path('webpack.mix.js'));
95100

101+
if(!$this->isVite) {
102+
copy(__DIR__ . '/../../stubs/inertia/views/app.mix.blade.php', resource_path('views/app.blade.php'));
103+
copy(__DIR__ . '/../../stubs/inertia/.babelrc', base_path('.babelrc'));
104+
copy(__DIR__ . '/../../stubs/inertia/webpack.config.js', base_path('webpack.config.js'));
105+
copy(__DIR__ . '/../../stubs/inertia/webpack.mix.js', base_path('webpack.mix.js'));
106+
copy(__DIR__ . '/../../stubs/inertia/js/app.mix.js', resource_path('js/app.js'));
107+
} else {
108+
copy(__DIR__ . '/../../stubs/inertia/views/app.vite.blade.php', resource_path('views/app.blade.php'));
109+
copy(__DIR__ . '/../../stubs/inertia/vite.config.js', base_path('vite.config.js'));
110+
copy(__DIR__ . '/../../stubs/inertia/js/app.vite.js', resource_path('js/app.js'));
111+
copy(__DIR__ . '/../../stubs/common/postcss.config.js', base_path('postcss.config.js'));
112+
}
113+
96114
$this->info('Jetstream ui scaffolding replaced successfully.');
97115
$this->comment('Please execute the "npm install && npm run dev" command to build your assets.');
98116
}
@@ -103,12 +121,6 @@ public function replaceLivewire()
103121
$this->updateNodePackages(function ($packages) {
104122
return [
105123
'@alpinejs/collapse' => '^3.4.2',
106-
'alpinejs' => '^3.4.2',
107-
'autoprefixer' => '^10.3.7',
108-
'postcss' => '^8.3.9',
109-
'tailwindcss' => '^3.0.7',
110-
'@tailwindcss/forms' => '^0.4.0',
111-
'@tailwindcss/typography' => '^0.5.0',
112124
'perfect-scrollbar' => '^1.5.2'
113125
] + $packages;
114126
});
@@ -124,7 +136,6 @@ public function replaceLivewire()
124136
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/api', resource_path('views/api'));
125137
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/auth', resource_path('views/auth'));
126138
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/components', resource_path('views/components'));
127-
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/layouts', resource_path('views/layouts'));
128139
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/profile', resource_path('views/profile'));
129140
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/livewire/views/teams', resource_path('views/teams'));
130141

@@ -136,9 +147,20 @@ public function replaceLivewire()
136147

137148
// Assets
138149
copy(__DIR__ . '/../../stubs/livewire/tailwind.config.js', base_path('tailwind.config.js'));
139-
copy(__DIR__ . '/../../stubs/livewire/webpack.mix.js', base_path('webpack.mix.js'));
140150
copy(__DIR__ . '/../../stubs/livewire/css/app.css', resource_path('css/app.css'));
141-
copy(__DIR__ . '/../../stubs/livewire/js/app.js', resource_path('js/app.js'));
151+
152+
if(!$this->isVite) {
153+
copy(__DIR__ . '/../../stubs/livewire/views/layouts/app.mix.blade.php', resource_path('views/layouts/app.blade.php'));
154+
copy(__DIR__ . '/../../stubs/livewire/views/layouts/guest.mix.blade.php', resource_path('views/layouts/guest.blade.php'));
155+
copy(__DIR__ . '/../../stubs/livewire/webpack.mix.js', base_path('webpack.mix.js'));
156+
copy(__DIR__ . '/../../stubs/livewire/js/app.mix.js', resource_path('js/app.js'));
157+
} else {
158+
copy(__DIR__ . '/../../stubs/livewire/views/layouts/app.vite.blade.php', resource_path('views/layouts/app.blade.php'));
159+
copy(__DIR__ . '/../../stubs/livewire/views/layouts/guest.vite.blade.php', resource_path('views/layouts/guest.blade.php'));
160+
copy(__DIR__ . '/../../stubs/livewire/vite.config.js', base_path('webpack.mix.js'));
161+
copy(__DIR__ . '/../../stubs/livewire/js/app.vite.js', resource_path('js/app.js'));
162+
copy(__DIR__ . '/../../stubs/common/postcss.config.js', base_path('postcss.config.js'));
163+
}
142164

143165
// Icons
144166
$this->requireComposerPackages('blade-ui-kit/blade-heroicons:^1.2');
@@ -203,21 +225,6 @@ protected static function updateNodePackages(callable $callback, $dev = true)
203225
);
204226
}
205227

206-
/**
207-
* Delete the "node_modules" directory and remove the associated lock files.
208-
*
209-
* @return void
210-
*/
211-
protected static function flushNodeModules()
212-
{
213-
tap(new Filesystem, function ($files) {
214-
$files->deleteDirectory(base_path('node_modules'));
215-
216-
$files->delete(base_path('yarn.lock'));
217-
$files->delete(base_path('package-lock.json'));
218-
});
219-
}
220-
221228
/**
222229
* Replace a given string within a given file.
223230
*
@@ -230,4 +237,24 @@ protected function replaceInFile($search, $replace, $path)
230237
{
231238
file_put_contents($path, str_replace($search, $replace, file_get_contents($path)));
232239
}
240+
241+
protected function replaceFavIcon()
242+
{
243+
(new Filesystem)->ensureDirectoryExists(base_path('public'));
244+
copy(__DIR__ . '/../../stubs/common/favicon.ico', base_path('public/favicon.ico'));
245+
}
246+
247+
protected function writeLogo()
248+
{
249+
$logo = PHP_EOL . '<fg=bright-blue>
250+
██╗ ██╗ ██╗ ██╗██╗
251+
██║ ██╔╝ ██║ ██║██║
252+
█████╔╝█████╗██║ ██║██║
253+
██╔═██╗╚════╝██║ ██║██║
254+
██║ ██╗ ╚██████╔╝██║
255+
╚═╝ ╚═╝ ╚═════╝ ╚═╝
256+
</>' . PHP_EOL;
257+
258+
return $this->line($logo);
259+
}
233260
}

stubs/common/favicon.ico

32.5 KB
Binary file not shown.

stubs/common/postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

stubs/inertia/css/app.css

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
11
@import 'tailwindcss/base';
22
@import 'tailwindcss/components';
3-
@import 'vue-toastification/dist/index.css';
4-
@import 'perfect-scrollbar/css/perfect-scrollbar.css';
53
@import 'tailwindcss/utilities';
6-
7-
.dark .ps__rail-y,
8-
.dark .ps__rail-x {
9-
background-color: transparent !important;
10-
}
11-
12-
.Vue-Toastification__toast {
13-
padding: 0 !important;
14-
box-shadow: none !important;
15-
}
16-
17-
.Vue-Toastification__toast--default,
18-
.Vue-Toastification__toast--success,
19-
.Vue-Toastification__toast--info,
20-
.Vue-Toastification__toast--error {
21-
background-color: transparent !important;
22-
}

stubs/inertia/js/Components/ActionMessage.vue

Lines changed: 0 additions & 17 deletions
This file was deleted.

stubs/inertia/js/Components/ActionSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
</template>
1515

1616
<script setup>
17-
import SectionTitle from '@/Components/SectionTitle'
17+
import SectionTitle from '@/Components/SectionTitle.vue'
1818
</script>

stubs/inertia/js/Components/ApplicationMark.vue

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
<template>
2-
<input type="checkbox" :value="value" v-model="proxyChecked"
3-
class="text-purple-500 border-gray-300 rounded focus:border-purple-300 focus:ring focus:ring-purple-500 dark:border-gray-600 dark:bg-dark-eval-1 dark:focus:ring-offset-dark-eval-1">
2+
<input
3+
type="checkbox"
4+
:value="value"
5+
v-model="proxyChecked"
6+
class="text-purple-500 border-gray-300 rounded focus:border-purple-300 focus:ring focus:ring-purple-500 dark:border-gray-600 dark:bg-dark-eval-1 dark:focus:ring-offset-dark-eval-1">
47
</template>
58

6-
<script>
7-
export default {
8-
emits: ['update:checked'],
9+
<script setup>
10+
import { computed } from 'vue'
911
10-
props: {
11-
checked: {
12-
type: [Array, Boolean],
13-
default: false,
14-
},
15-
value: {
16-
default: null,
17-
},
12+
const emit = defineEmits(['update:checked'])
13+
14+
const props = defineProps({
15+
checked: {
16+
type: [Array, Boolean],
17+
default: false,
18+
},
19+
value: {
20+
type: String,
21+
default: null,
1822
},
23+
})
1924
20-
computed: {
21-
proxyChecked: {
22-
get() {
23-
return this.checked;
24-
},
25+
const proxyChecked = computed({
26+
get() {
27+
return props.checked
28+
},
2529
26-
set(val) {
27-
this.$emit("update:checked", val);
28-
},
29-
},
30+
set(val) {
31+
emit('update:checked', val)
3032
},
31-
}
33+
})
3234
</script>
Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
2+
<Modal :show="show" :max-width="maxWidth" :closeable="closeable" @close="close">
33
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 dark:bg-dark-eval-1">
44
<div class="sm:flex sm:items-start">
55
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
@@ -21,39 +21,32 @@
2121
</div>
2222

2323
<div class="px-6 py-4 bg-gray-100 text-right dark:bg-dark-eval-2">
24-
<slot name="footer">
25-
</slot>
24+
<slot name="footer"></slot>
2625
</div>
27-
</modal>
26+
</Modal>
2827
</template>
2928

30-
<script>
31-
import { defineComponent } from 'vue'
32-
import Modal from './Modal.vue'
33-
34-
export default defineComponent({
35-
emits: ['close'],
36-
37-
components: {
38-
Modal,
39-
},
40-
41-
props: {
42-
show: {
43-
default: false
44-
},
45-
maxWidth: {
46-
default: '2xl'
47-
},
48-
closeable: {
49-
default: true
50-
},
51-
},
52-
53-
methods: {
54-
close() {
55-
this.$emit('close')
56-
},
57-
}
58-
})
29+
<script setup>
30+
import Modal from '@/Components/Modal.vue'
31+
32+
const emit = defineEmits(['close'])
33+
34+
defineProps({
35+
show: {
36+
type: Boolean,
37+
default: false,
38+
},
39+
maxWidth: {
40+
type: String,
41+
default: '2xl',
42+
},
43+
closeable: {
44+
type: Boolean,
45+
default: true,
46+
},
47+
})
48+
49+
const close = () => {
50+
emit('close')
51+
}
5952
</script>

0 commit comments

Comments
 (0)