awcodes / overlook

An app overview widget for Filament panels.
MIT License
158 stars 11 forks source link

The Design is broken in the latest version of the package after the upgrade to Filament v.3 #41

Closed kingmaker-agm closed 3 months ago

kingmaker-agm commented 3 months ago

Filament Version

v3

Plugin Version

v2.2.0

PHP Version

PHP 8.2.10

Problem description

After the Upgrade to the Filament v3 from v2, the UI was broken for the Overlook plugin v2.2 in the Dashboard page.

Overlook v3

The older version v1.3 worked perfectly for me Overlook v2

Story

I upgraded my Filament version in the project from v2 to v3. Along with that I upgraded all the other dependencies in the project.

Expected behavior

The Cards are having smaller Heights.

Steps to reproduce

  1. Create a Filament 2 project and include the Overlook widget
  2. Now upgrade the Filament to version 3 along with other dependency version upgrades
  3. View the overlook plugin.

Reproduction repository

https://github.com/kingmaker-agm/stories-filament

Relevant log output

No response

awcodes commented 3 months ago

In Filament v3 the asset system changed. See the second paragraph under Installation in the Read.me for the plugin.

kingmaker-agm commented 3 months ago

Hi @awcodes

I am not using any Custom Themes in the Filament. I'm not much familiar with the Custom Themes and the project doesn't have Vite setup.

Can you suggest me how to get this Plugin working with the Default Filament provided Theme itself?

The documentation and the resources are not very clear.

awcodes commented 3 months ago

You have to use a custom theme with filament v3.

kingmaker-agm commented 3 months ago

For People who don't know how to Setup the Custom Theme in the Filament, please follow the Instruction below.

Custom Theme Setup

Official Filament Documentation

  1. Create a Custom Theme using the Artisan command php artisan make:filament-theme
  2. This will create few files in the system a. postcss.config.js b. resources/css/filament/admin/theme.css c. resources/css/filament/admin/tailwind.config.js
  3. Add the newly created Theme CSS to the vite.config.js files input array configuration
    
    import { defineConfig } from 'vite';
    import laravel from 'laravel-vite-plugin';

export default defineConfig({ plugins: [ laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/admin/theme.css', ], refresh: true, }), ], });

4. Add the `awcodes/overlook` blade views into the newly created `resources/css/filament/admin/tailwind.config.js`
```js
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/**/*.php',
        './resources/views/filament/**/*.blade.php',
        './vendor/filament/**/*.blade.php',

        // Awcodes Overlook plugin
        './vendor/awcodes/overlook/resources/views/**/*.blade.php',
    ],
};
  1. Add the new Theme CSS in Panel Configuration within the AdminPanelProvider Service provider file
    class AdminPanelProvider extends PanelProvider
    {
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
           // other configs
           ->viteTheme('resources/css/filament/admin/theme.css');
    }
    }
  2. Finally Build the Assets using npm run build

This will get the Issue resolved.

Troubleshooting

Failed to load PostCSS config

If you are facing Issue during the Build process mentioning "unable to load the PostCSS config", you can resolve it by one of two ways #### Method 1: change the export style in the `postcss.config.js` ```js export default {} ``` to ```js module.exports = {} ``` #### Method 2 (Recommended): change the module type in `package.json` ```json { "type": "module" } ```
kingmaker-agm commented 3 months ago

@awcodes

Won't you think its appropriate to provide a Default Stylesheet for Users who are not using a Custom Filament Theme?

I believe as a package, it should be easier to use and work out-of-the-box if possible.

Thanks ;-)

awcodes commented 3 months ago

This is why it requires a custom theme. https://filamentphp.com/docs/3.x/support/assets#using-tailwind-css-in-plugins

kingmaker-agm commented 3 months ago

Hi @awcodes

I'm not stating that the Custom Themes was not a useful or less significant.

What I suggest is that Overlook plugin can detect if we are using a Custom Theme or not, and then decide on provide with a pre-built CSS for that case alone with all the Tailwind CSS classes used in your plugin.

We can simple copy the markup in the repository and paste it in the Tailwind playground to get the necessary TailwindCSS Utilities for your views, Am I right?

Sample Generation

```css .absolute { position: absolute; } .relative { position: relative; } .inset-0 { inset: 0px; } .bottom-3 { bottom: 0.75rem; } .left-0 { left: 0px; } .right-4 { right: 1rem; } .top-8 { top: 2rem; } .h-24 { height: 6rem; } .w-auto { width: auto; } .overflow-hidden { overflow: hidden; } .rounded-xl { border-radius: 0.75rem; } .bg-gradient-to-tr { background-image: linear-gradient(to top right, var(--tw-gradient-stops)); } .from-gray-100 { --tw-gradient-from: #f3f4f6 var(--tw-gradient-from-position); --tw-gradient-to: rgb(243 244 246 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); } .from-gray-950 { --tw-gradient-from: #030712 var(--tw-gradient-from-position); --tw-gradient-to: rgb(3 7 18 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); } .via-white { --tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), #fff var(--tw-gradient-via-position), var(--tw-gradient-to); } .to-gray-900 { --tw-gradient-to: #111827 var(--tw-gradient-to-position); } .to-white { --tw-gradient-to: #fff var(--tw-gradient-to-position); } .px-3 { padding-left: 0.75rem; padding-right: 0.75rem; } .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; } .text-3xl { font-size: 1.875rem; line-height: 2.25rem; } .font-bold { font-weight: 700; } .font-medium { font-weight: 500; } .leading-none { line-height: 1; } .text-gray-300 { --tw-text-opacity: 1; color: rgb(209 213 219 / var(--tw-text-opacity)); } .text-gray-400 { --tw-text-opacity: 1; color: rgb(156 163 175 / var(--tw-text-opacity)); } .text-gray-600 { --tw-text-opacity: 1; color: rgb(75 85 99 / var(--tw-text-opacity)); } .opacity-20 { opacity: 0.2; } .ring-2 { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); } .transition { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; } .hover\:ring-2:hover { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); } .focus\:ring-2:focus { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); } .group:hover .group-hover\:-rotate-12 { --tw-rotate: -12deg; transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); } .group:hover .group-hover\:scale-110 { --tw-scale-x: 1.1; --tw-scale-y: 1.1; transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); } .group:hover .group-hover\:opacity-40 { opacity: 0.4; } .group:hover .group-hover\:opacity-80 { opacity: 0.8; } @media (prefers-color-scheme: dark) { .dark\:from-gray-950 { --tw-gradient-from: #030712 var(--tw-gradient-from-position); --tw-gradient-to: rgb(3 7 18 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); } .dark\:to-gray-900 { --tw-gradient-to: #111827 var(--tw-gradient-to-position); } .dark\:text-gray-300 { --tw-text-opacity: 1; color: rgb(209 213 219 / var(--tw-text-opacity)); } .dark\:text-gray-400 { --tw-text-opacity: 1; color: rgb(156 163 175 / var(--tw-text-opacity)); } .dark\:opacity-20 { opacity: 0.2; } .group:hover .dark\:group-hover\:opacity-80 { opacity: 0.8; } } ```

Please do let me know If I want to try to implement this and provide an PR?

awcodes commented 3 months ago

A custom theme is the recommended usage according to filament so I would prefer to stick with that to keep css bloat to a minimum.

kingmaker-agm commented 3 months ago

Thanks for Clarifying, Adam !!