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

Include Bootstrap inside codebase #1238

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"prettier/prettier": true,
"no-descending-specificity": null,
"scss/no-global-function-names": null,
"scss/comment-no-empty": null
"scss/comment-no-empty": null,
"scss/at-if-no-null": null,
"scss/at-extend-no-missing-placeholder": null,
"no-invalid-position-at-import-rule": null
}
}
8 changes: 4 additions & 4 deletions docs/assets/src/scss/docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
// here to be available to "variables"
@import '../../../../src/scss/utilities/colors_vars';
@import '../../../../src/scss/variables';
@import '../../../../node_modules/bootstrap/scss/functions';
@import '../../../../src/scss/bootstrap/functions';
@import '../../../../src/scss/custom/mixins/buttons';
// here to override any conflicting "node_modules/bootstrap/scss/functions" definitions
@import '../../../../node_modules/bootstrap/scss/variables';
@import '../../../../node_modules/bootstrap/scss/mixins';
// here to override any conflicting "bootstrap/scss/functions" definitions
@import '../../../../src/scss/bootstrap/variables';
@import '../../../../src/scss/bootstrap/mixins';
// Load docs components
@import 'colors';
@import 'nav';
Expand Down
51 changes: 18 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@
"stylelint-scss": "^6.10.0"
},
"dependencies": {
"@popperjs/core": "^2.11.2",
"@popperjs/core": "^2.11.6",
"@splidejs/splide": "^3.6.12",
"@types/bootstrap": "^5.2.6",
"accessible-autocomplete": "^2.0.4",
"accessible-autocomplete": "^3.0.1",
"animejs": "^3.2.1",
"bootstrap": "5.2.3",
"design-tokens-italia": "^1.1.1",
"just-validate": "^3.10.0",
"masonry-layout": "^4.2.2",
Expand Down
8 changes: 8 additions & 0 deletions src/js/bootstrap-italia.entry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

import '../scss/bootstrap-italia.scss'

import { loadPlugin } from './load-plugin'
Expand Down
8 changes: 8 additions & 0 deletions src/js/bootstrap-italia.esm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

export { default as CarouselBI } from './plugins/carousel-bi'
export { default as InputNumber } from './plugins/input-number'
export { default as Dimmer } from './plugins/dimmer'
Expand Down
8 changes: 8 additions & 0 deletions src/js/icons.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

import '../svg/it-android.svg'
import '../svg/it-android-square.svg'
import '../svg/it-apple.svg'
Expand Down
8 changes: 8 additions & 0 deletions src/js/load-plugin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

export const loadPlugin = (module) => {
// Trick Rollup.js to keep JavaScript.
let obj = {
Expand Down
28 changes: 18 additions & 10 deletions src/js/plugins/accept-overlay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import BaseComponent from 'bootstrap/js/src/base-component.js'
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

import { reflow } from 'bootstrap/js/src/util'
import BaseComponent from './base-component.js'

import { reflow } from './util/index'
import { cookies } from './util/cookies'
import SelectorEngine from 'bootstrap/js/src/dom/selector-engine'
import SelectorEngine from './dom/selector-engine'

const NAME = 'acceptoverlay'

Expand Down Expand Up @@ -113,12 +121,12 @@ class AcceptOverlay extends BaseComponent {
* Data Api implementation
* ------------------------------------------------------------------------
*/

const acceptOverlays = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
if (acceptOverlays.length > 0) {
acceptOverlays.forEach((element) => {
AcceptOverlay.getOrCreateInstance(element, { service: element.dataset.bsAcceptFrom })
})
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
const acceptOverlays = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
if (acceptOverlays.length > 0) {
acceptOverlays.forEach((element) => {
AcceptOverlay.getOrCreateInstance(element, { service: element.dataset.bsAcceptFrom })
})
}
}

export default AcceptOverlay
38 changes: 16 additions & 22 deletions src/js/plugins/accordion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import BaseComponent from 'bootstrap/js/src/base-component.js'
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

import BaseComponent from './base-component.js'

import EventHandler from 'bootstrap/js/src/dom/event-handler'
import SelectorEngine from 'bootstrap/js/src/dom/selector-engine'
import EventHandler from './dom/event-handler'
import SelectorEngine from './dom/selector-engine'

import { focusSimbling } from './util/dom'

Expand Down Expand Up @@ -82,28 +90,14 @@ class Accordion extends BaseComponent {
* Data Api implementation
* ------------------------------------------------------------------------
*/
/*const accordions = SelectorEngine.find(SELECTOR_HEADBTN_WRAPPER)
accordions.forEach((acc) => {
Accordion.getOrCreateInstance(acc)
})*/

/*const accordionToggles = SelectorEngine.find(SELECTOR_HEADBTN)
accordionToggles.forEach((toggle) => {
EventHandler.one(toggle, EVENT_KEYDOWN_DATA_API, (evt) => {
const parent = toggle.closest(SELECTOR_HEADBTN_WRAPPER)
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_HEADBTN, function (evt) {
const parent = this.closest(SELECTOR_HEADBTN_WRAPPER)
if (parent) {
const accordion = Accordion.getOrCreateInstance(parent)
accordion.handleKeyDown(evt.key, toggle, evt)
accordion.handleKeyDown(evt.key, this, evt)
}
})
})*/

EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_HEADBTN, function (evt) {
const parent = this.closest(SELECTOR_HEADBTN_WRAPPER)
if (parent) {
const accordion = Accordion.getOrCreateInstance(parent)
accordion.handleKeyDown(evt.key, this, evt)
}
})
}

export default Accordion
66 changes: 64 additions & 2 deletions src/js/plugins/alert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
import { default as BSAlert } from 'bootstrap/js/src/alert'
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* This a fork of Bootstrap: Initial license and original file name below
* Bootstrap (v5.2.3): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

class Alert extends BSAlert {}
import EventHandler from './dom/event-handler'
import BaseComponent from './base-component'
import { enableDismissTrigger } from './util/component-functions'

/**
* Constants
*/

const NAME = 'alert'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`

const EVENT_CLOSE = `close${EVENT_KEY}`
const EVENT_CLOSED = `closed${EVENT_KEY}`
const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'

/**
* Class definition
*/

class Alert extends BaseComponent {
// Getters
static get NAME() {
return NAME
}

// Public
close() {
const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE)

if (closeEvent.defaultPrevented) {
return
}

this._element.classList.remove(CLASS_NAME_SHOW)

const isAnimated = this._element.classList.contains(CLASS_NAME_FADE)
this._queueCallback(() => this._destroyElement(), this._element, isAnimated)
}

// Private
_destroyElement() {
this._element.remove()
EventHandler.trigger(this._element, EVENT_CLOSED)
this.dispose()
}
}

/**
* Data API implementation
*/

enableDismissTrigger(Alert, 'close')

export default Alert
16 changes: 12 additions & 4 deletions src/js/plugins/backToTop.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import BaseComponent from 'bootstrap/js/src/base-component.js'
/**
* --------------------------------------------------------------------------
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/

import BaseComponent from './base-component.js'

import EventHandler from 'bootstrap/js/src/dom/event-handler'
import SelectorEngine from 'bootstrap/js/src/dom/selector-engine'
import Manipulator from 'bootstrap/js/src/dom/manipulator'
import EventHandler from './dom/event-handler'
import SelectorEngine from './dom/selector-engine'
import Manipulator from './dom/manipulator'

import onDocumentScroll from './util/on-document-scroll'
import { documentScrollTo } from './util/tween'
Expand Down
Loading
Loading