Skip to content
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

Less 3.8 #14

Merged
merged 26 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c12f2be
package – update css-compile script to use --math
calvinjuarez Jul 16, 2018
828ad7e
maps – begin converting to DRs
calvinjuarez Jul 17, 2018
fb6c4e9
each – use each() for loops (WIP)
calvinjuarez Jul 17, 2018
e3819dc
breakpoints – fix breakpoint JS after converting to DR maps
calvinjuarez Jul 17, 2018
512b7f8
each – replace all #each-* loop with each or #for-*
calvinjuarez Jul 17, 2018
b565efa
dev, meta – steal nice stuff from #12
calvinjuarez Nov 28, 2018
b801400
plugins – fix lint warnings/errors
calvinjuarez Nov 29, 2018
fd68b7b
_tables – fix .table-responsive output order
calvinjuarez Dec 5, 2018
94a03d1
_navbar – fix .navbar-expand output order
calvinjuarez Dec 6, 2018
787c6b4
README – update to match true min version required
seanCodes Dec 16, 2018
085e7b6
plugins/theme-color-level – more readable code
seanCodes Dec 16, 2018
c41f725
README – replace the other, less easy ways of installing
calvinjuarez Dec 16, 2018
95c71c3
_grid-framework – restore comment
calvinjuarez Dec 16, 2018
19f2b6f
README – wording edits
seanCodes Dec 16, 2018
0bf3c70
_functions – restore commented Sass
calvinjuarez Dec 16, 2018
942a7bc
README – more wording edits
seanCodes Dec 16, 2018
d888c5e
README – remove clone note
calvinjuarez Dec 16, 2018
1c4f82b
plugins/breakpoints – remove parseUnit(); fix nextBreakpoint ESLint i…
calvinjuarez Dec 16, 2018
9c63386
rename plugin `keys` → `map-keys`
seanCodes Feb 18, 2019
68f97a4
_grid-framework – revert loop renaming
seanCodes Feb 21, 2019
8a300b6
_transition – revert var renaming
seanCodes Feb 21, 2019
2bf786a
breakpoints – put long comments on own line
seanCodes Feb 21, 2019
6917d55
restore color-function plugins
seanCodes Feb 24, 2019
d2d9ef9
restore usages of color functions
seanCodes Feb 24, 2019
33642be
change color functions to handle rulesets vs lists
seanCodes Feb 24, 2019
d65fa87
fix bug in ruleset-to-map conversion
seanCodes Feb 25, 2019
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
51 changes: 18 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ The code is currently aligned with [Bootstrap v4.1.3](https://github.com/twbs/bo

## Getting Started

Options for installing Bootstrap Less in your project:
Options for installing Bootstrap Less in your project (Less v3.7+ required):

- Install with [npm](https://www.npmjs.com/): `npm install bootstrap-less-port`
- Install with [yarn](https://yarnpkg.com/): `yarn add bootstrap-less-port`
- Clone the repo: `git clone https://github.com/seanCodes/bootstrap-less-port.git`
- [Download the latest release](https://github.com/seanCodes/bootstrap-less-port/archive/master.zip)
- Install with [npm](https://www.npmjs.com/): `npm install less bootstrap-less-port`
- Install with [yarn](https://yarnpkg.com/): `yarn add less bootstrap-less-port`

Note that this code is only necessary if you want to use Less in your project and want to import and/or customize Bootstrap’s variables, mixins or styles. If you plan to use the CSS framework wholesale, you can get the compiled CSS files from the main Bootstrap repo, so there’s no need for this code.

Expand All @@ -36,48 +34,34 @@ your-project/
└─ ...
```

In this case, you could then import what you need into `custom.less` using relative paths to the files in the `node_modules` folder:
In this case, you could then import what you need into `custom.less` using module-relative paths:

```less
// custom.less


// Required Files
@import "../../node_modules/bootstrap-less-port/less/_functions";
@import "../../node_modules/bootstrap-less-port/less/_variables";
@import "../../node_modules/bootstrap-less-port/less/_mixins";
@import "bootstrap-less-port/less/_functions";
@import "bootstrap-less-port/less/_variables";
@import "bootstrap-less-port/less/_mixins";

// Optional Files
@import "../../node_modules/bootstrap-less-port/less/_reboot";
@import "../../node_modules/bootstrap-less-port/less/_utilities";
@import "../../node_modules/bootstrap-less-port/less/_type";
@import "../../node_modules/bootstrap-less-port/less/_grid";
@import "bootstrap-less-port/less/_reboot";
@import "bootstrap-less-port/less/_utilities";
@import "bootstrap-less-port/less/_type";
@import "bootstrap-less-port/less/_grid";
...
```

This approach is recommended since it will result in a smaller CSS file by omitting the styles you don’t need. (Just be aware that some files are dependent on others.)

Alternatively, you can get the entire framework by importing the main `bootstrap.less` file:
Alternatively, you can get the entire framework by importing the default `bootstrap.less` file:

```less
// custom.less


@import "../../node_modules/bootstrap-less-port/less/bootstrap";
```

#### Usage with `less-plugin-npm-import`

If you’re using `lessc` on the command line, you can use [`less-plugin-npm-import`](https://github.com/less/less-plugin-npm-import) to import the files in a much cooler and more maintainable way. Just install the plugin via npm and then reference the Bootstrap Less files using the plugin’s default `npm://` prefix:

```less
@import "npm://bootstrap-less-port/less/bootstrap";
```

Then simply include the `--npm-import` flag when compiling:

```bash
$ lessc --npm-import file.less file.css
@import "bootstrap-less-port";
```


Expand All @@ -89,7 +73,7 @@ The recommended way of customizing Bootstrap is to modify the provided variables
// custom.less


@import "../../node_modules/bootstrap-less-port/less/bootstrap";
@import "bootstrap-less-port";

// Variable Overrides
@body-bg: @black;
Expand Down Expand Up @@ -124,9 +108,7 @@ This port attempts to mirror the source Sass files as closely as possible in ord

Note: The plugins are included using the [`@plugin`](http://lesscss.org/features/#plugin-atrules-feature) at-rule instead of as arguments to the `lessc` CLI. This was intentionally done since most Less GUI compilers don’t allow you to customize the command-line arguments.

0. **Maps** Less has no _native_ concept of maps, which are used extensively in the Bootstrap Sass files. They can be emulated, however, by using a comma-separated list of space-separated lists, which is what is done in this port.

0. **Loops** Sass `@for` and `@each` loops have been replaced with Less’s method of looping which requires unique, named mixins for every loop. This is a bit clunky and means that the loops used in this port are verbose and difficult to read, but it’s the best we’ve got until I can figure out how to overcome this with a plugin.
0. **Loops** Where possible, Sass `@each` loops have been replaced by the Less `each()` function. Sass `@for` directives are trickier and have no direct Less analog (yet), so they are replaced with a method of looping which requires unique, named mixins for every loop. This is a bit clunky, and means that in some places, loops are verbose and difficult to read, but it’s the best we’ve got until I can figure out how to overcome this with a plugin or Less has a native equivalent.

In order to make catching bugs easier, the Sass versions of most for/each loops have been kept in the code, commented, above the Less versions.

Expand All @@ -139,6 +121,9 @@ This port attempts to mirror the source Sass files as closely as possible in ord

## Contributing

- Clone the repo: `git clone https://github.com/seanCodes/bootstrap-less-port.git`
- [Download the latest release](https://github.com/seanCodes/bootstrap-less-port/archive/master.zip)

For bugs, feature-requests, or issues with the compiled CSS, please create an issue in the main Bootstrap repo.

For errors or bugs related to the ported code, please submit a pull request or create an issue.
Expand Down
9 changes: 2 additions & 7 deletions less/_alert.less
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,8 @@
// @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level));
// }
//}
#each-theme-color-alert(@i) when (@i =< length(@theme-colors)) {
@item: extract(@theme-colors, @i);
@color: extract(@item, 1);

each(@theme-colors, #(@value, @color) {
.alert-@{color} {
#alert-variant(theme-color-level(@color, @alert-bg-level), theme-color-level(@color, @alert-border-level), theme-color-level(@color, @alert-color-level));
}

#each-theme-color-alert((@i + 1));
} #each-theme-color-alert(1);
})
10 changes: 2 additions & 8 deletions less/_badge.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@
// @include badge-variant($value);
// }
//}
#each-theme-color-badge(@i: 1) when (@i =< length(@theme-colors)) {
@item: extract(@theme-colors, @i);
@color: extract(@item, 1);
@value: extract(@item, 2);

each(@theme-colors, #(@value, @color) {
.badge-@{color} {
#badge-variant(@value);
}

#each-theme-color-badge((@i + 1));
} #each-theme-color-badge();
})
20 changes: 4 additions & 16 deletions less/_buttons.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,11 @@ fieldset:disabled a.btn {
// @include button-variant($value, $value);
// }
//}
#each-theme-color-button(@i: 1) when (@i =< length(@theme-colors)) {
@item: extract(@theme-colors, @i);
@color: extract(@item, 1);
@value: extract(@item, 2);

each(@theme-colors, #(@value, @color) {
.btn-@{color} {
#button-variant(@value, @value);
}

#each-theme-color-button((@i + 1));
} #each-theme-color-button();
})

//@each $color, $value in $theme-colors {
// .btn-outline-#{$color} {
Expand All @@ -83,17 +77,11 @@ fieldset:disabled a.btn {
// }
// }
//}
#each-theme-color-button-outline(@i: 1) when (@i =< length(@theme-colors)) {
@item: extract(@theme-colors, @i);
@color: extract(@item, 1);
@value: extract(@item, 2);

each(@theme-colors, #(@value, @color) {
.btn-outline-@{color} {
#button-outline-variant(@value);
}

#each-theme-color-button-outline((@i + 1));
} #each-theme-color-button-outline();
})


//
Expand Down
30 changes: 5 additions & 25 deletions less/_custom-forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,14 @@

//@each $lang, $value in $custom-file-text {
// &:lang(#{$lang}) ~ .custom-file-label::after {
// content: @value;
// content: $value;
// }
//}
#each-language-file-input-label(@i: 1) when (@i =< length(@custom-file-text)) {
// LESS PORT: This gets really funky because a single key/value pair has to be handled
// differently than a list of key/values. This is because Less will see a single key/value as
// a space-separated list of two items instead of a comma-separated list of just a single
// item, so logic is added to handle both cases.
& when (length(extract(@custom-file-text, @i)) = 1) {
@lang: extract(@custom-file-text, 1);
@text: extract(@custom-file-text, 2);

&:lang(@{lang}) ~ .custom-file-label::after {
content: @text;
}
}
& when (length(extract(@custom-file-text, @i)) = 2) {
@item: extract(@custom-file-text, @i);
@lang: extract(@item, 1);
@text: extract(@item, 2);

&:lang(@{lang}) ~ .custom-file-label::after {
content: @text;
}

#each-language-file-input-label((@i + 1));
each(@custom-file-text, #(@value, @lang) {
&:lang(@{lang}) ~ .custom-file-label::after {
content: @value;
}
} #each-language-file-input-label();
});
}

.custom-file-label {
Expand Down
20 changes: 3 additions & 17 deletions less/_functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// Utility mixins and functions for evaluating source code across our variables, maps, and mixins.

@plugin "plugins/index";
@plugin "plugins/map-get";

// Implements a keys function like map-keys
@plugin "plugins/keys";

// Ascending
// Used to evaluate Sass maps like our grid breakpoints.
Expand Down Expand Up @@ -67,22 +69,6 @@
//}
@plugin "plugins/color-yiq";

// Retreive color Sass maps
//@function color($key: "blue") {
// @return map-get($colors, $key);
//}
@plugin "plugins/color";

//@function theme-color($key: "primary") {
// @return map-get($theme-colors, $key);
//}
@plugin "plugins/theme-color";

//@function gray($key: "100") {
// @return map-get($grays, $key);
//}
@plugin "plugins/gray";

// Request a theme color level
//@function theme-color-level($color-name: "primary", $level: 0) {
// $color: theme-color($color-name);
Expand Down
4 changes: 2 additions & 2 deletions less/_grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
//
// Common styles for small and large grid columns

#output-columns() when (@enable-grid-classes) {
& when (@enable-grid-classes) {
#make-grid-columns();
} #output-columns();
}
12 changes: 4 additions & 8 deletions less/_list-group.less
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,9 @@
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.

//@each @color, @value in @theme-colors {
// #list-group-item-variant(@color, theme-color-level(@color, -9), theme-color-level(@color, 6));
//@each $color, $value in $theme-colors {
// @include list-group-item-variant($color, theme-color-level($color, -9), theme-color-level($color, 6));
//}
#each-theme-color-list-group(@i: 1) when (@i =< length(@theme-colors)) {
@color: extract(extract(@theme-colors, @i), 1);

each(@theme-colors, #(@value, @color) {
#list-group-item-variant(@color, theme-color-level(@color, -9), theme-color-level(@color, 6));

#each-theme-color-list-group((@i + 1));
} #each-theme-color-list-group();
});
Loading