Skip to content

Commit

Permalink
chore(style): merge slick-grid.scss & slick-bootstrap.scss into 1 file (
Browse files Browse the repository at this point in the history
#1501)

* chore(style): merge slick-grid.scss & slick-bootstrap.scss into 1 file
  • Loading branch information
ghiscoding authored May 3, 2024
1 parent 3649484 commit e82d092
Show file tree
Hide file tree
Showing 20 changed files with 549 additions and 637 deletions.
2 changes: 2 additions & 0 deletions docs/column-functionalities/Formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ export interface FormatterResultObject {
```
### Example of a Custom Formatter with HTML string
For example, we will use our optional SVG icons `.mdi` with a `boolean` as input data, and display a (fire) icon when `True` or a (snowflake) when `False`. This custom formatter is actually display in the [UI sample](#ui-sample) shown below.
```ts
// create a custom Formatter with the Formatter type
const myCustomCheckboxFormatter: Formatter = (row: number, cell: number, value: any, columnDef: Column, dataContext: any) =>
Expand Down
14 changes: 7 additions & 7 deletions docs/migrations/migration-to-5.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The goal of this new release was mainly to improve UI/UX (mostly for Dark Mode)
> **NOTE:** if you come from an earlier version, please make sure to follow each migrations in their respected order (review previous migration guides)
For most breaking changes, a quick Search & Replace in your code editor should suffice.
For most breaking changes, a quick Search & Replace in your code editor should suffice.

## Changes

Expand Down Expand Up @@ -64,7 +64,7 @@ or move the class to the parent container and have both the icon & the text inhe
```

#### SASS variables
A lot of SASS variables were changed, we recommend that you take a look at the [_variables.scss](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/_variables.scss) file to compare them with yours SASS overrides and fix any SASS build issues. For example a lot of the ms-select variables and all Flatpickr related variables were deleted. Also a lot of the icon related variables got updated (icons now have the suffix `-icon-svg-path` for the SVG vector path). If you want create your own SVGs in pure CSS, you can use the `generateSvgStyle()` function from our [`sass-utilities.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/sass-utilities.scss) (take a look at the [`slickgrid-icons.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/slickgrid-icons.scss) on its usage)
A lot of SASS variables were changed, we recommend that you take a look at the [_variables.scss](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/_variables.scss) file to compare them with yours SASS overrides and fix any SASS build issues. For example a lot of the ms-select variables and all Flatpickr related variables were deleted. Also a lot of the icon related variables got updated (icons now have the suffix `-icon-svg-path` for the SVG vector path). If you want create your own SVGs in pure CSS, you can use the `generateSvgStyle()` function from our [`svg-utilities.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/svg-utilities.scss) (take a look at the [`slickgrid-icons.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/slickgrid-icons.scss) on its usage)

#### SASS (dart-sass) `math` polyfills are removed
When SASS (dart-sass) released their version 1.33 (~3 years ago), it caused a ton of console warnings (and a lot of unhappy users) in projects that were using `/` in their SASS files (for math division) instead of their new `math.div()` function. To avoid seeing all these warnings, I added a temporary polyfill at the time (that piece of code was actually copied from the Bootstrap project). That polyfill patch was put in place about 3 years ago, so I'm assuming that most users have already upgraded their SASS version and already fixed all of these warnings. So, I think it's time to remove this polyfill because it was really meant to be a temp patch. If you see these warnings coming back, then a suggestion would be to use the SASS option `--quiet-upstream`.
Expand Down Expand Up @@ -187,7 +187,7 @@ The biggest change that you will have to do is the min/max date setting when usi

prepareGrid() {
this.columnDefinitions = [{
id: 'finish', field: 'finish', name: 'Finish',
id: 'finish', field: 'finish', name: 'Finish',
editor: {
model: Editors.date,
- editorOptions: { minDate: 'today' } as FlatpickrOption,
Expand All @@ -204,17 +204,17 @@ The work on this subject started over a month ago in version [v4.6.0](https://gi

An example of the previous `internalColumnEditor` usage was when you wanted to modify or push a new item to the editor collection array (see below). In the past, you could not simply push directly to `collection.editor.collection`, you really had to use the mapping of `collection.internalColumnEditor.collection`... this is thankfully gone, you can now use the same and original `collection.editor.collection` 🎉

For example, previously, to add an item to the editor/filter collection
For example, previously, to add an item to the editor/filter collection
```diff
this.columnDefinitions = [{ id: 'complexity', editor: { model: Editors.singleSelect, collection: [{ value: 1, label: 'Simple' }, /*...*/ ] } }];

// then adding an item would previously require to use `internalColumnEditor`
// then adding an item would previously require to use `internalColumnEditor`
// after grid init, our `editor` became `internalColumnEditor
- const complexityEditor = this.columnDefinitions[0].internalColumnEditor;
- const complexityEditor = this.columnDefinitions[0].internalColumnEditor;
complexityEditor.collection.push({ value: 9, label: 'Hard' });

// NOW with this new release, adding a new item to the collection is as simple as referencing the original object
+ const complexityEditor = this.columnDefinitions[0].editor;
+ const complexityEditor = this.columnDefinitions[0].editor;
complexityEditor.collection.push({ value: 9, label: 'Hard' });
```

Expand Down
6 changes: 3 additions & 3 deletions docs/styling/styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For example, if we take the following 3 SASS variables (`$slick-header-menu-disp
> **Note:** you could use `:host` to only change current grid styling, **however** there are many DOM elements that are appended to the DOM `body` (Grid Menu, Column Picker, Select Filter/Editor, Context Menu, ...) and the styles **will not** be applied when simply using `:host` and so in most cases you would want to use `:root` (if possible) to make a global change which will also work with elements appended to the `body`. Also note that `:root` is not available in Salesforce LWC and so you unfortunately won't be able to style everything in Salesforce.
### Using Custom SVGs with SASS
You could use Custom SVGs and create your own Theme and/or a different set of SVG Icons, each of the icons used in Slickgrid-Universal has an associated SASS variables ending with the suffix `"icon-svg-path"` which allow you to override any of the SVG vector path. All SVG icons are generated by following AntFu's [icons in pure CSS](https://antfu.me/posts/icons-in-pure-css) approach. If you want create your own SVGs in pure CSS, you can use the `generateSvgStyle()` function from our [`sass-utilities.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/sass-utilities.scss) (take a look at the [`slickgrid-icons.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/slickgrid-icons.scss) on its usage)
You could use Custom SVGs and create your own Theme and/or a different set of SVG Icons, each of the icons used in Slickgrid-Universal has an associated SASS variables ending with the suffix `"icon-svg-path"` which allow you to override any of the SVG vector path. All SVG icons are generated by following AntFu's [icons in pure CSS](https://antfu.me/posts/icons-in-pure-css) approach. If you want create your own SVGs in pure CSS, you can use the `generateSvgStyle()` function from our [`svg-utilities.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/svg-utilities.scss) (take a look at the [`slickgrid-icons.scss`](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/slickgrid-icons.scss) on its usage)

##### with SVG
```scss
Expand All @@ -92,9 +92,9 @@ $slick-checkbox-icon-checked-svg-path: "M10,17L5,12L6.41,10.58L10,14.17L17.59,6.
```

### SVG icons
The project has a few built-in icons (sort, grouping, row detail, row move, row selection) and you can change them via SASS (or CSS with a bit more work). For that reason, all Styling Themes Since this release now has pure CSS SVG icons, I decided to delete any Font-Awesome references (mostly in the Bootstrap Theme) because all the built-in icons are now all SVG icons (sort, grouping, row detail, row move) (you can change them using SASS). However, there are a few plugins that use external icons via CSS classes (mostly all menu plugins like Header Menu, Grid Menu, Content Menu, ...) and for that reason **all Styling Themes now include default SVG icons** (even the Bootstrap Theme).
The project has a few built-in icons (sort, grouping, row detail, row move, row selection) and you can change them via SASS (or CSS with a bit more work). For that reason, all Styling Themes Since this release now has pure CSS SVG icons, I decided to delete any Font-Awesome references (mostly in the Bootstrap Theme) because all the built-in icons are now all SVG icons (sort, grouping, row detail, row move) (you can change them using SASS). However, there are a few plugins that use external icons via CSS classes (mostly all menu plugins like Header Menu, Grid Menu, Content Menu, ...) and for that reason **all Styling Themes now include default SVG icons** (even the Bootstrap Theme).

What if you want to use your own font/SVG library?
What if you want to use your own font/SVG library?
This can be answered in 2 parts:
1. the built-in icons can only be changed via SASS (or CSS with extra work), see above on how to change them.
2. for all other area using icons via CSS classes (e.g. all menu plugins), you can use the "lite" Themes and then make sure to update all the menu plugins with the correct CSS classes, for example the global grid options of the Grid Menu is configured with the following CSS classes and you'll want to remap them with the correct CSS classes to fit your need:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @import '@slickgrid-universal/common/dist/styles/sass/slickgrid-theme-material.scss';

.grid5 {
--slick-cell-display: inline-flex;
.slick-cell {
display: inline-flex;
align-items: center;
column-gap: 4px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export default class Example14 {
{
command: 'help',
title: 'Help!',
iconCssClass: 'mdi mdi-circle-question',
iconCssClass: 'mdi mdi-help-circle',
positionOrder: 66,
action: () => alert('Please Help!'),
},
Expand Down
7 changes: 4 additions & 3 deletions packages/common/src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import 'vanilla-calendar-picker/build/vanilla-calendar.min';

// SASS utils to generate SVGs
@import './sass-utilities';
@import './svg-utilities';

/*
* SlickGrid-Universal theming variables, used by all Themes
Expand Down Expand Up @@ -93,6 +93,7 @@ $slick-cell-odd-active-background-color: darken($slick-grid-c
$slick-cell-padding-top-bottom: 5px !default;
$slick-cell-padding-left-right: 6px !default;
$slick-cell-padding: $slick-cell-padding-top-bottom $slick-cell-padding-left-right !default;
$slick-icon-with-text-valign: middle !default;

/** 4x available slick-pane (top, bottom, left, right) */
$slick-pane-top-border-top: none !default;
Expand Down Expand Up @@ -269,8 +270,6 @@ $slick-group-border-bottom: 2px solid silver !de
$slick-group-totals-formatter-color: gray !default;
$slick-group-totals-formatter-bgcolor: #fff !default;
$slick-group-totals-formatter-font-size: 14px !default;
$slick-group-totals-text-background: white !default;
$slick-group-totals-text-color: gray !default;

/** Row Detail View Plugin */
$slick-detail-view-icon-color: $slick-primary-color !default;
Expand Down Expand Up @@ -486,6 +485,7 @@ $slick-large-editor-text-color: #333 !default;
$slick-text-editor-border: 1px solid #e2e2e2 !default;
$slick-text-editor-border-radius: $slick-editor-input-border-radius !default;
$slick-text-editor-background: #ffffff !default;
$slick-text-editor-color: #333 !default;
$slick-text-editor-margin-bottom: 0 !default;
$slick-text-editor-margin-left: -2px !default; /* negative number to cancel inside padding */
$slick-text-editor-right-input-margin-left: calc(#{$slick-text-editor-margin-left} + 9px) !default;
Expand Down Expand Up @@ -1081,6 +1081,7 @@ $slick-empty-data-warning-z-index: 10 !default;
--slick-large-editor-background-color: var(--slick-base-dark-menu-bg-color);
--slick-large-editor-border: 2px solid #565656;
--slick-large-editor-text-color: var(--slick-base-dark-text-color);
--slick-text-editor-color: var(--slick-base-dark-text-color);
--slick-header-menu-button-icon-color: var(--slick-menu-color);
--slick-text-editor-background: var(--slick-base-dark-menu-bg-color);
--slick-pagination-button-border: 1px solid #696969;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/styles/colors.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './sass-utilities';
@import './svg-utilities';

/* icon/text colors */
// we'll use the same color set as text-colors defined in Bootstrap 4 (ref: https://getbootstrap.com/docs/4.5/utilities/colors/)
Expand Down
5 changes: 0 additions & 5 deletions packages/common/src/styles/extra-styling.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ $slick-padding-max-count: 30;
}
}

.slick-cell {
.button-style {
height: 100%;
}
}
.button-style {
cursor: pointer;
background-color: var(--slick-button-style-bg-color, $slick-button-style-bg-color);
Expand Down
Loading

0 comments on commit e82d092

Please sign in to comment.