granite-bootstrap
Wrapping of *Bootstrap CSS* as Polymer web componentto be used as shared style in full ShadowDOM mode
[ This description is mirrored from README.md at github.com/LostInBrittany/granite-bootstrap on 2019-05-22 ]
granite-bootstrap
granite-bootstrap is a wrapping of Bootstrap CSS as Polymer shared styles modules (i.e. inside <dom-module>
tags).
This project replaces and updates polymer-bootstrap, that won't be updated anymore Hybrid Polymer element, 1.x-2.x ready
Doc & demo
https://lostinbrittany.github.io/granite-bootstrap
Using granite-bootstrap modules
Using polymer style modules modules is a two-step process: you need to use ES6 module imports to import the module, and a <style>
tag to include the styles in the correct place.
To use granite-bootstrap in an element:
1. Add the dependency
Add the dependency to the package.json
of your application:
"dependencies": {
[...]
"polymer3-granite-bootstrap": "^4.0.0-polymer3"
}
And then recover them via bower install
.
2. Import the granite-bootstrap module you want to use
Usually you will simply want to import granite-bootstrap.js
(wrap around bootstrap.css
) or granite-bootstrap-min.js
(wrap around bootstrap.min.css
).
Supossing you're using the standard folder locations for your components:
import 'granite-bootstrap.js';
3. Inside your component, use granite-bootstrap as shared style
In your element's template you add the include for the granite-bootstrap module:
<style include="granite-bootstrap"></style>
A complete example
<!-- import the module -->
<script type="module">
import 'granite-bootstrap.js';
</script>
<dom-module id="x-foo">
<template>
<!-- include the style module by name -->
<style include="granite-bootstrap"></style>
<style>:host { display: block; }</style>
Hi
</template>
<script>Polymer({is: 'x-foo'});</script>
</dom-module>
Generating the style modules
To generate the style modules we use the granite-css-modularizer node script:
1. Clone the repository and recover the dependencies of granite-css-modularizer
Clone the granite-css-modularizer repository and recover the dependencies using yarn
(or npm
) :
$ yarn install
yarn install v1.2.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.83s.
2. Recover Bootstrap
Recover Bootstrap distribution using yarn
(or npm
):
$ yarn add bootstrap@4.0.0-beta.2
yarn add v1.2.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "bootstrap@4.0.0-beta.2" has unmet peer dependency "jquery@1.9.1 - 3".
warning "bootstrap@4.0.0-beta.2" has unmet peer dependency "popper.js@^1.12.3".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ bootstrap@4.0.0-beta.2
Done in 0.55s.
Currently granite-bootstrap uses Bootstrap version 4.0.0-beta.2, if you need another version you can change simply install it.
3. Generate the components
Using NodeJS and the granite-css-modularizer.js
to transform Bootstrap CSS files into polymer elements.
$ node ../granite-css-modularizer.js ./node_modules/bootstrap/dist/css ./css_modules/granite-bootstrap
After executing it, a series of HTML files is generated in the ./css_modules/granite-bootstrap
folder, each one corresponding to a Bootstrap CSS file.
$ ls ./css_modules/granite-bootstrap/*.html
granite-bootstrap-grid.html granite-bootstrap-grid-min.html granite-bootstrap.html granite-bootstrap-min.html granite-bootstrap-reboot.html granite-bootstrap-reboot-min.html
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Install dependencies and run the demo
Run npm install from the repo directory:
npm install
Run the Polymer development server from the root project directory:
polymer serve --open
Note on semver versioning
I'm aligning the versions of this element with Bootstrap version, in order to make easier to choose the right version
License
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Dependencies
- @polymer/polymer#3.3.0
- Released
- 2019-11-07
- Maturity
- IMPORTED
- License
- MIT License
Compatibility
- Framework
- Polymer 3.0+
- Polymer 2.0+ in 4.0.0-0
- Browser
- Browser Independent
granite-bootstrap - Vaadin Add-on Directory
Wrapping of *Bootstrap CSS* as Polymer web componentto be used as shared style in full ShadowDOM modeDocumentation
Online Demo
View on NPM
GitHub Homepage
Issue tracker
granite-bootstrap version 3.3.7-3
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 3.3.7-4
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 3.3.7-5
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 4.0.2-beta.2.1
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 4.0.2-beta.2.2
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 4.0.0-0
### Dependencies
* polymer#Polymer/polymer#1.9 - 2
granite-bootstrap version 4.1.1-0
### Dependencies
* @polymer/polymer#^3.0.0
* bootstrap#^4.1.1
granite-bootstrap version 4.1.1-1
### Dependencies
* @polymer/polymer#^3.0.0
* bootstrap#^4.1.1
granite-bootstrap version 4.3.1-0
### Dependencies
* @polymer/polymer#3.3.0
granite-bootstrap version 4.3.1-1
### Dependencies
* @polymer/polymer#3.3.0