-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feature: basic theming support #148
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
danharrin
reviewed
Mar 10, 2021
danharrin
reviewed
Mar 10, 2021
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
…t into feature/theming
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds support for very basic theming. With the changes here, you will be able to change the three main colours used by Filament.
Customising colours
The main colours used by Filament can be customised using CSS variables.
The colours available are:
primary
success
danger
white
blue
gray
All of the colours, apart from
white
, can be adjusted on a scale of 100-900 (just like Tailwind), e.g.To customise the colour
white
, use--f-white: #ffffff
as the CSS variable.Quickly generating a theme
If you want to quickly generate a theme with all of the variable names stubbed out, you can use the
make:filament-theme
command:This will generate a new CSS file
resources/css/filament/custom-theme.css
with all of the CSS variables commented out. Uncomment the variables you wish to modify and insert your own colours.You can then use the instructions below to include / enqueue the CSS file on the Filament pages.
Enqueuing custom scripts and styles
This pull request also adds support for including your own styles and scripts inside of Filament, this can be done using the 2 methods:
Filament::registerScript($name, $script)
Filament::registerStyle($name, $style)
These scripts will be included after Filament's own scripts and Livewire's scripts but before any stacks. @danharrin Do we want to change this so that they come after stacks instead?
Passing data to the front-end
If your custom scripts rely on some data from the server, you can pass this along using
Filament::provideToScript($variables)
:Calling these new methods
You should call these new methods inside of a service provider's
boot
method. This will ensure Filament's core classes as well as Laravel's are registered with the container.Filament::serving
There is also a new
Filament::serving($callback)
method that can be used to only run your Filament related logic when Filament is actually being served to the user.You can use it like this:
Behind the scenes, this will just register an event listener for the
Filament\Events\ServingFilament
event. This means you could also pass through a Laravel-style callable array too.The callback function will receive the
ServingFilament
event too, which has apublic $request
variable so you can run some logic based on the current request context.