Skip to content

Commit

Permalink
Start a modular embeddable library based on Bootstrap
Browse files Browse the repository at this point in the history
- Prefix CSS classes, variables, data attributes, parent selector
- Organize styles and components for importing as needed
  • Loading branch information
eliot-akira committed Sep 14, 2024
1 parent 8de555b commit 462d976
Show file tree
Hide file tree
Showing 181 changed files with 23,096 additions and 7,444 deletions.
153 changes: 153 additions & 0 deletions accordion.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
//
// Base styles
//

.#{$class-prefix}accordion {
// scss-docs-start accordion-css-vars
--#{$prefix}accordion-color: #{$accordion-color};
--#{$prefix}accordion-bg: #{$accordion-bg};
--#{$prefix}accordion-transition: #{$accordion-transition};
--#{$prefix}accordion-border-color: #{$accordion-border-color};
--#{$prefix}accordion-border-width: #{$accordion-border-width};
--#{$prefix}accordion-border-radius: #{$accordion-border-radius};
--#{$prefix}accordion-inner-border-radius: #{$accordion-inner-border-radius};
--#{$prefix}accordion-btn-padding-x: #{$accordion-button-padding-x};
--#{$prefix}accordion-btn-padding-y: #{$accordion-button-padding-y};
--#{$prefix}accordion-btn-color: #{$accordion-button-color};
--#{$prefix}accordion-btn-bg: #{$accordion-button-bg};
--#{$prefix}accordion-btn-icon: #{escape-svg($accordion-button-icon)};
--#{$prefix}accordion-btn-icon-width: #{$accordion-icon-width};
--#{$prefix}accordion-btn-icon-transform: #{$accordion-icon-transform};
--#{$prefix}accordion-btn-icon-transition: #{$accordion-icon-transition};
--#{$prefix}accordion-btn-active-icon: #{escape-svg($accordion-button-active-icon)};
--#{$prefix}accordion-btn-focus-box-shadow: #{$accordion-button-focus-box-shadow};
--#{$prefix}accordion-body-padding-x: #{$accordion-body-padding-x};
--#{$prefix}accordion-body-padding-y: #{$accordion-body-padding-y};
--#{$prefix}accordion-active-color: #{$accordion-button-active-color};
--#{$prefix}accordion-active-bg: #{$accordion-button-active-bg};
// scss-docs-end accordion-css-vars
}

.#{$class-prefix}accordion-button {
position: relative;
display: flex;
align-items: center;
width: 100%;
padding: var(--#{$prefix}accordion-btn-padding-y) var(--#{$prefix}accordion-btn-padding-x);
@include font-size($font-size-base);
color: var(--#{$prefix}accordion-btn-color);
text-align: left; // Reset button style
background-color: var(--#{$prefix}accordion-btn-bg);
border: 0;
@include border-radius(0);
overflow-anchor: none;
@include transition(var(--#{$prefix}accordion-transition));

&:not(.#{$class-prefix}collapsed) {
color: var(--#{$prefix}accordion-active-color);
background-color: var(--#{$prefix}accordion-active-bg);
box-shadow: inset 0 calc(-1 * var(--#{$prefix}accordion-border-width)) 0 var(--#{$prefix}accordion-border-color); // stylelint-disable-line function-disallowed-list

&::after {
background-image: var(--#{$prefix}accordion-btn-active-icon);
transform: var(--#{$prefix}accordion-btn-icon-transform);
}
}

// Accordion icon
&::after {
flex-shrink: 0;
width: var(--#{$prefix}accordion-btn-icon-width);
height: var(--#{$prefix}accordion-btn-icon-width);
margin-left: auto;
content: "";
background-image: var(--#{$prefix}accordion-btn-icon);
background-repeat: no-repeat;
background-size: var(--#{$prefix}accordion-btn-icon-width);
@include transition(var(--#{$prefix}accordion-btn-icon-transition));
}

&:hover {
z-index: 2;
}

&:focus {
z-index: 3;
outline: 0;
box-shadow: var(--#{$prefix}accordion-btn-focus-box-shadow);
}
}

.#{$class-prefix}accordion-header {
margin-bottom: 0;
}

.#{$class-prefix}accordion-item {
color: var(--#{$prefix}accordion-color);
background-color: var(--#{$prefix}accordion-bg);
border: var(--#{$prefix}accordion-border-width) solid var(--#{$prefix}accordion-border-color);

&:first-of-type {
@include border-top-radius(var(--#{$prefix}accordion-border-radius));

> .#{$class-prefix}accordion-header .#{$class-prefix}accordion-button {
@include border-top-radius(var(--#{$prefix}accordion-inner-border-radius));
}
}

&:not(:first-of-type) {
border-top: 0;
}

// Only set a border-radius on the last item if the accordion is collapsed
&:last-of-type {
@include border-bottom-radius(var(--#{$prefix}accordion-border-radius));

> .#{$class-prefix}accordion-header .#{$class-prefix}accordion-button {
&.#{$class-prefix}collapsed {
@include border-bottom-radius(var(--#{$prefix}accordion-inner-border-radius));
}
}

> .#{$class-prefix}accordion-collapse {
@include border-bottom-radius(var(--#{$prefix}accordion-border-radius));
}
}
}

.#{$class-prefix}accordion-body {
padding: var(--#{$prefix}accordion-body-padding-y) var(--#{$prefix}accordion-body-padding-x);
}


// Flush accordion items
//
// Remove borders and border-radius to keep accordion items edge-to-edge.

.#{$class-prefix}accordion-flush {
> .#{$class-prefix}accordion-item {
border-right: 0;
border-left: 0;
@include border-radius(0);

&:first-child { border-top: 0; }
&:last-child { border-bottom: 0; }

// stylelint-disable selector-max-class
> .#{$class-prefix}accordion-collapse,
> .#{$class-prefix}accordion-header .#{$class-prefix}accordion-button,
> .#{$class-prefix}accordion-header .#{$class-prefix}accordion-button.#{$class-prefix}collapsed {
@include border-radius(0);
}
// stylelint-enable selector-max-class
}
}

@if $enable-dark-mode {
@include color-mode(dark) {
.#{$class-prefix}accordion-button::after {
--#{$prefix}accordion-btn-icon: #{escape-svg($accordion-button-icon-dark)};
--#{$prefix}accordion-btn-active-icon: #{escape-svg($accordion-button-active-icon-dark)};
}
}
}
66 changes: 0 additions & 66 deletions admin/index.php

This file was deleted.

68 changes: 68 additions & 0 deletions alert.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// Base styles
//

.#{$class-prefix}alert {
// scss-docs-start alert-css-vars
--#{$prefix}alert-bg: transparent;
--#{$prefix}alert-padding-x: #{$alert-padding-x};
--#{$prefix}alert-padding-y: #{$alert-padding-y};
--#{$prefix}alert-margin-bottom: #{$alert-margin-bottom};
--#{$prefix}alert-color: inherit;
--#{$prefix}alert-border-color: transparent;
--#{$prefix}alert-border: #{$alert-border-width} solid var(--#{$prefix}alert-border-color);
--#{$prefix}alert-border-radius: #{$alert-border-radius};
--#{$prefix}alert-link-color: inherit;
// scss-docs-end alert-css-vars

position: relative;
padding: var(--#{$prefix}alert-padding-y) var(--#{$prefix}alert-padding-x);
margin-bottom: var(--#{$prefix}alert-margin-bottom);
color: var(--#{$prefix}alert-color);
background-color: var(--#{$prefix}alert-bg);
border: var(--#{$prefix}alert-border);
@include border-radius(var(--#{$prefix}alert-border-radius));
}

// Headings for larger alerts
.#{$class-prefix}alert-heading {
// Specified to prevent conflicts of changing $headings-color
color: inherit;
}

// Provide class for links that match alerts
.#{$class-prefix}alert-link {
font-weight: $alert-link-font-weight;
color: var(--#{$prefix}alert-link-color);
}


// Dismissible alerts
//
// Expand the right padding and account for the close button's positioning.

.#{$class-prefix}alert-dismissible {
padding-right: $alert-dismissible-padding-r;

// Adjust close link position
.#{$class-prefix}btn-close {
position: absolute;
top: 0;
right: 0;
z-index: $stretched-link-z-index + 1;
padding: $alert-padding-y * 1.25 $alert-padding-x;
}
}


// scss-docs-start alert-modifiers
// Generate contextual modifier classes for colorizing the alert
@each $state in map-keys($theme-colors) {
.#{$class-prefix}alert-#{$state} {
--#{$prefix}alert-color: var(--#{$prefix}#{$state}-text-emphasis);
--#{$prefix}alert-bg: var(--#{$prefix}#{$state}-bg-subtle);
--#{$prefix}alert-border-color: var(--#{$prefix}#{$state}-border-subtle);
--#{$prefix}alert-link-color: var(--#{$prefix}#{$state}-text-emphasis);
}
}
// scss-docs-end alert-modifiers
80 changes: 80 additions & 0 deletions alert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import BaseComponent, { DATA_PREFIX } from './base-component'
import EventHandler from './dom/event-handler'
import { enableDismissTrigger } from './utilities/component-functions'
import { defineJQueryPlugin } from './utilities'

/**
* Constants
*/

const NAME = 'alert'
const DATA_KEY = `${DATA_PREFIX}.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()
}

// Static
static jQueryInterface(config) {
return this.each(function () {
const data = Alert.getOrCreateInstance(this)

if (typeof config !== 'string') {
return
}

if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
throw new TypeError(`No method named "${config}"`)
}

data[config](this)
})
}
}

/**
* Data API implementation
*/

enableDismissTrigger(Alert, 'close')

/**
* jQuery
*/

// defineJQueryPlugin(Alert)

export default Alert
Loading

0 comments on commit 462d976

Please sign in to comment.