Skip to content

Refactored 'HasModels' trait and improved styling setup #6

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

Merged
merged 1 commit into from
Aug 26, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
build
composer.lock
coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
package-lock.json
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"name": "step2dev/lazy-ui",
"description": "Lazy UI is a Laravel package that provides a set of Blade components to rapidly build forms with Tailwind CSS and Daisy UI.",
"keywords": [
"lazy ui",
"component",
"components",
"daisy ui",
"design-system",
"framework",
"laravel",
"lazy component ui",
"lazy form",
"daisy ui"
"lazy ui",
"tailwind",
"tailwindcss",
"ui-library"
],
"homepage": "https://github.com/step2dev/lazy-ui",
"license": "MIT",
Expand Down
Empty file added docs/.gitkeep
Empty file.
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "lazy-component",
"version": "1.0.0",
"description": "TallStack components",
"license": "MIT",
"keywords": [
"design-system",
"tailwindcss",
"components",
"ui-library",
"component",
"framework",
"tailwind"
],
"dependencies": {
"alpinejs": "^3.13.0",
"theme-change": "^2.5.0"
},
"devDependencies": {
"daisyui": "^3.6.3",
"sanitize-html": "^2.11.0",
"tailwindcss": "^3.3.3"
}
}
1 change: 1 addition & 0 deletions resources/css/lazy.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import "tailwind";
@import "./components/toast";
9 changes: 9 additions & 0 deletions resources/css/tailwind.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer utilities {
.pause {
animation-play-state: paused;
}
}
17 changes: 17 additions & 0 deletions resources/js/components/themeswitcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { themeChange } from 'theme-change'

themeChange()
let themeToggleBtn = document.querySelector('[data-toggle-theme]')

document.addEventListener('DOMContentLoaded', () => {
if (themeToggleBtn) {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
themeToggleBtn.classList.add('swap-active')
} else {
themeToggleBtn.classList.remove('swap-active')
}
}
})



85 changes: 85 additions & 0 deletions resources/tailwind.lazy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const defaultTheme = require('tailwindcss/defaultTheme')
const colors = require("tailwindcss/colors");

/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ['class', '[data-mode="dark"]'],
presets: [
//
],
content: [
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
'./app/View/**/*.php',
'./vendor/step2dev/lazy-ui/src/Component/**/*.blade.php',
'./vendor/step2dev/lazy-ui/resources/views/*.blade.php',
'./app/Livewire/**/*Table.php',
],
theme: {
extend: {
fontFamily: {
'sans': ['Nunito', ...defaultTheme.fontFamily.sans],
// 'serif': ['Roboto', ...defaultTheme.fontFamily.serif],
// 'mono': ['Roboto', ...defaultTheme.fontFamily.mono],
// 'body': ['Roboto'],
},
transitionProperty: {
multiple: "width, height, backgroundColor, border-radius"
}
}
},
variants: {
extend: {
opacity: ['disabled']
}
},
plugins: [
// require('@tailwindcss/typography'),
require('@tailwindcss/forms')({
strategy: 'class',
}),
// require('@tailwindcss/aspect-ratio'),
// require('@tailwindcss/typography'),
require('daisyui')
],
daisyui: {
themes: [
"light",
"dark",
"cupcake",
"bumblebee",
"emerald",
"corporate",
"synthwave",
"retro",
"cyberpunk",
"valentine",
"halloween",
"garden",
"forest",
"aqua",
"lofi",
"pastel",
"fantasy",
"wireframe",
"black",
"luxury",
"dracula",
"cmyk",
"autumn",
"business",
"acid",
"lemonade",
"night",
"coffee",
"winter",
],// true: all themes | false: only light + dark | array: specific themes like this ["light", "dark", "cupcake"]
darkTheme: "dark", // name of one of the included themes for dark mode
base: false, // applies background color and foreground color for root element by default
styled: true, // include daisyUI colors and design decisions for all components
utils: true, // adds responsive and modifier utility classes
rtl: false, // rotate style direction from left-to-right to right-to-left. You also need to add dir="rtl" to your html tag and install `tailwindcss-flip` plugin for Tailwind CSS.
prefix: "", // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors)
logs: true, // Shows info about daisyUI version and used config in the console when building your CSS
},
}
2 changes: 1 addition & 1 deletion resources/views/badge.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'label' => '',
'icon' => ''
])
<span {{ $attributes->merge(['class'=> 'badge'.($icon ? ' gap-2' : '')]) }}>{{ $icon }}{{ $label ?: $slot }}</span>
<span {{ $attributes->merge(['class'=> ($icon ? ' gap-2' : '')]) }}>{{ $icon }}{{ $label ?: $slot }}</span>
2 changes: 1 addition & 1 deletion resources/views/btn/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
])

<x-lazy-btn xs light :href="$href" {{ $attributes }}>
<i class="bx bxs-plus-square"></i> {!! $slot !!}
{{ $slot ?: __('lazy::buttons.create') }}
</x-lazy-btn>
10 changes: 0 additions & 10 deletions src/Traits/HasModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@ trait HasModels

private ?bool $hasAlpineModel = null;

final public function hasBoundModel(): bool
{
return $this->hasLivewireModel() || $this->hasAlpineModel();
}

final public function hasLivewireModel(): bool
{
return $this->hasLivewireModel ??= $this->attributes->whereStartsWith('wire:model')->first();
}

final public function hasAlpineModel(): bool
{
return $this->hasAlpineModel ??= $this->attributes->whereStartsWith('x-model')->first();
}
}