Skip to content

Commit

Permalink
Merge branch 'main' into feature/supra-bars
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond authored Nov 30, 2021
2 parents f02b880 + 3fbe7c1 commit 3c6f353
Show file tree
Hide file tree
Showing 61 changed files with 1,602 additions and 1,508 deletions.
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"path": "./dist/css/boosted-grid.css",
"maxSize": "9.8 kB"
"maxSize": "9.9 kB"
},
{
"path": "./dist/css/boosted-grid.min.css",
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Ignore docs files
/_site/
# Hugo resources folder
# Hugo files
/resources/
/.hugo_build.lock

# Numerous always-ignore extensions
*.diff
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ Read the [Getting started page](https://boosted.orange.com/docs/5.1/getting-star
[![npm version](https://img.shields.io/npm/v/boosted)](https://www.npmjs.com/package/boosted)
[![Packagist Prerelease](https://img.shields.io/packagist/vpre/Orange-OpenSource/Orange-Boosted-Bootstrap.svg)](https://packagist.org/packages/Orange-OpenSource/Orange-Boosted-Bootstrap)
[![NuGet](https://img.shields.io/nuget/vpre/boosted)](https://www.nuget.org/packages/boosted/absoluteLatest)
[![peerDependencies Status](https://img.shields.io/david/peer/Orange-OpenSource/Orange-Boosted-Bootstrap)](https://david-dm.org/Orange-OpenSource/Orange-Boosted-Bootstrap?type=peer)
[![devDependency Status](https://img.shields.io/david/dev/Orange-OpenSource/Orange-Boosted-Bootstrap)](https://david-dm.org/Orange-OpenSource/Orange-Boosted-Bootstrap?type=dev)
[![CSS gzip size](https://img.badgesize.io/Orange-OpenSource/Orange-Boosted-Bootstrap/main/dist/css/boosted.min.css?compression=gzip&label=CSS%20gzip%20size)](https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap/blob/main/dist/css/boosted.min.css)
[![CSS Brotli size](https://img.badgesize.io/Orange-OpenSource/Orange-Boosted-Bootstrap/main/dist/css/boosted.min.css?compression=brotli&label=CSS%20Brotli%20size)](https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap/blob/main/dist/css/boosted.min.css)
[![JS gzip size](https://img.badgesize.io/Orange-OpenSource/Orange-Boosted-Bootstrap/main/dist/js/boosted.min.js?compression=gzip&label=JS%20gzip%20size)](https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap/blob/main/dist/js/boosted.min.js)
Expand Down
3 changes: 0 additions & 3 deletions build/.pa11yci.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"standard": "WCAG2AA",
"level": "error",
"concurrency": 1,
"defaults": {
"wait": 3000,
"runners": [
"axe"
],
"timeout": 100000,
"hideElements": ".bd-search, [id*='tarteaucitron'], #TableOfContents, .text-primary, .navbar-light .navbar-brand, .accordion-button:not(.collapsed), .active, [aria-current], select:disabled, [disabled] label, [disabled] + label, .modal, .bd-example nav, .badge.rounded-pill.bg-info.text-white, .exclude-from-pa11y-analysis, a.disabled, .form-check.form-switch",
"ignore": [
"heading-order",
Expand Down
203 changes: 62 additions & 141 deletions build/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,173 +11,94 @@

const path = require('path')
const rollup = require('rollup')
const glob = require('glob')
const { babel } = require('@rollup/plugin-babel')
const banner = require('./banner.js')

const rootPath = path.resolve(__dirname, '../js/dist/')
const plugins = [
babel({
// Only transpile our source code
exclude: 'node_modules/**',
// Include the helpers in each file, at most one copy of each
babelHelpers: 'bundled'
})
]
const bsPlugins = {
Data: path.resolve(__dirname, '../js/src/dom/data.js'),
EventHandler: path.resolve(__dirname, '../js/src/dom/event-handler.js'),
Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'),
SelectorEngine: path.resolve(__dirname, '../js/src/dom/selector-engine.js'),
Alert: path.resolve(__dirname, '../js/src/alert.js'),
Base: path.resolve(__dirname, '../js/src/base-component.js'),
Button: path.resolve(__dirname, '../js/src/button.js'),
Carousel: path.resolve(__dirname, '../js/src/carousel.js'),
Collapse: path.resolve(__dirname, '../js/src/collapse.js'),
Dropdown: path.resolve(__dirname, '../js/src/dropdown.js'),
Modal: path.resolve(__dirname, '../js/src/modal.js'),
Offcanvas: path.resolve(__dirname, '../js/src/offcanvas.js'),
Popover: path.resolve(__dirname, '../js/src/popover.js'),
ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'),
Tab: path.resolve(__dirname, '../js/src/tab.js'),
Toast: path.resolve(__dirname, '../js/src/toast.js'),
Tooltip: path.resolve(__dirname, '../js/src/tooltip.js')
}

const defaultPluginConfig = {
external: [
bsPlugins.Data,
bsPlugins.Base,
bsPlugins.EventHandler,
bsPlugins.SelectorEngine
],
globals: {
[bsPlugins.Data]: 'Data',
[bsPlugins.Base]: 'Base',
[bsPlugins.EventHandler]: 'EventHandler',
[bsPlugins.SelectorEngine]: 'SelectorEngine'
}
}
const srcPath = path.resolve(__dirname, '../js/src/')
const jsFiles = glob.sync(srcPath + '/**/*.js')

const getConfigByPluginKey = pluginKey => {
switch (pluginKey) {
case 'Alert':
case 'Offcanvas':
case 'Tab':
return defaultPluginConfig

case 'Base':
case 'Button':
case 'Carousel':
case 'Collapse':
case 'Modal':
case 'ScrollSpy': {
const config = Object.assign(defaultPluginConfig)
config.external.push(bsPlugins.Manipulator)
config.globals[bsPlugins.Manipulator] = 'Manipulator'
return config
}
// Array which holds the resolved plugins
const resolvedPlugins = []

case 'Dropdown':
case 'Tooltip': {
const config = Object.assign(defaultPluginConfig)
config.external.push(bsPlugins.Manipulator, '@popperjs/core')
config.globals[bsPlugins.Manipulator] = 'Manipulator'
config.globals['@popperjs/core'] = 'Popper'
return config
}
// Trims the "js" extension and uppercases => first letter, hyphens, backslashes & slashes
const filenameToEntity = filename => filename.replace('.js', '')
.replace(/(?:^|-|\/|\\)[a-z]/g, str => str.slice(-1).toUpperCase())

case 'Popover':
return {
external: [
bsPlugins.Data,
bsPlugins.SelectorEngine,
bsPlugins.Tooltip
],
globals: {
[bsPlugins.Data]: 'Data',
[bsPlugins.SelectorEngine]: 'SelectorEngine',
[bsPlugins.Tooltip]: 'Tooltip'
}
}

case 'Toast':
return {
external: [
bsPlugins.Data,
bsPlugins.Base,
bsPlugins.EventHandler,
bsPlugins.Manipulator
],
globals: {
[bsPlugins.Data]: 'Data',
[bsPlugins.Base]: 'Base',
[bsPlugins.EventHandler]: 'EventHandler',
[bsPlugins.Manipulator]: 'Manipulator'
}
}

default:
return {
external: []
}
}
for (const file of jsFiles) {
resolvedPlugins.push({
src: file.replace('.js', ''),
dist: file.replace('src', 'dist'),
fileName: path.basename(file),
className: filenameToEntity(path.basename(file))
// safeClassName: filenameToEntity(path.relative(srcPath, file))
})
}

const utilObjects = new Set([
'Util',
'Sanitizer',
'Backdrop'
])

const domObjects = new Set([
'Data',
'EventHandler',
'Manipulator',
'SelectorEngine'
])

const build = async plugin => {
console.log(`Building ${plugin} plugin...`)
const globals = {}

const { external, globals } = getConfigByPluginKey(plugin)
const pluginFilename = path.basename(bsPlugins[plugin])
let pluginPath = rootPath
const bundle = await rollup.rollup({
input: plugin.src,
plugins: [
babel({
// Only transpile our source code
exclude: 'node_modules/**',
// Include the helpers in each file, at most one copy of each
babelHelpers: 'bundled'
})
],
external: source => {
// Pattern to identify local files
const pattern = /^(\.{1,2})\//

// It's not a local file, e.g a Node.js package
if (!pattern.test(source)) {
globals[source] = source
return true
}

if (utilObjects.has(plugin)) {
pluginPath = `${rootPath}/util/`
}
const usedPlugin = resolvedPlugins.find(plugin => {
return plugin.src.includes(source.replace(pattern, ''))
})

if (domObjects.has(plugin)) {
pluginPath = `${rootPath}/dom/`
}
if (!usedPlugin) {
throw new Error(`Source ${source} is not mapped!`)
}

const bundle = await rollup.rollup({
input: bsPlugins[plugin],
plugins,
external
// We can change `Index` with `UtilIndex` etc if we use
// `safeClassName` instead of `className` everywhere
globals[path.normalize(usedPlugin.src)] = usedPlugin.className
return true
}
})

await bundle.write({
banner: banner(pluginFilename),
banner: banner(plugin.fileName),
format: 'umd',
name: plugin,
name: plugin.className,
sourcemap: true,
globals,
generatedCode: 'es2015',
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
file: plugin.dist
})

console.log(`Building ${plugin} plugin... Done!`)
console.log(`Built ${plugin.className}`)
}

const main = async () => {
(async () => {
try {
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
const basename = path.basename(__filename)
const timeLabel = `[${basename}] finished`

console.log('Building individual plugins...')
console.time(timeLabel)

await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin)))

console.timeEnd(timeLabel)
} catch (error) {
console.error(error)

process.exit(1)
}
}

main()
})()
4 changes: 2 additions & 2 deletions build/change-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function replaceRecursively(file, oldVersion, newVersion) {
}

async function main(args) {
const [oldVersion, newVersion] = args
let [oldVersion, newVersion] = args

if (!oldVersion || !newVersion) {
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
Expand All @@ -66,7 +66,7 @@ async function main(args) {
}

// Strip any leading `v` from arguments because otherwise we will end up with duplicate `v`s
[oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg)
[oldVersion, newVersion] = [oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg)

try {
const files = await globby(GLOB, GLOBBY_OPTIONS)
Expand Down
38 changes: 12 additions & 26 deletions js/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,17 @@
* --------------------------------------------------------------------------
*/

import Alert from './src/alert'
import Button from './src/button'
import Carousel from './src/carousel'
import Collapse from './src/collapse'
import Dropdown from './src/dropdown'
import Modal from './src/modal'
import Offcanvas from './src/offcanvas'
import Popover from './src/popover'
import ScrollSpy from './src/scrollspy'
import Tab from './src/tab'
import Toast from './src/toast'
import Tooltip from './src/tooltip'
import '../node_modules/focus-visible/dist/focus-visible.js' // Boosted mod

export {
Alert,
Button,
Carousel,
Collapse,
Dropdown,
Modal,
Offcanvas,
Popover,
ScrollSpy,
Tab,
Toast,
Tooltip
}
export { default as Alert } from './src/alert'
export { default as Button } from './src/button'
export { default as Carousel } from './src/carousel'
export { default as Collapse } from './src/collapse'
export { default as Dropdown } from './src/dropdown'
export { default as Modal } from './src/modal'
export { default as Offcanvas } from './src/offcanvas'
export { default as Popover } from './src/popover'
export { default as ScrollSpy } from './src/scrollspy'
export { default as Tab } from './src/tab'
export { default as Toast } from './src/toast'
export { default as Tooltip } from './src/tooltip'
Loading

0 comments on commit 3c6f353

Please sign in to comment.