Giter Site home page Giter Site logo

codewisenate / digital-gov-block-theme-supplemental Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 12.08 MB

Additional scripts and styles for the WordPress digital.gov.bc.ca block theme added with the Assets Loader plugin

JavaScript 71.38% HTML 1.00% SCSS 27.42% TypeScript 0.20%

digital-gov-block-theme-supplemental's Introduction

BCGov Block Theme support framework

Provides supplemental scripts and styles

A Vite-based BCGov Block Theme augmentation framework for adding additional built scripts and styles to a specific installation.

This allows for SCSS and vanilla Javascript module-based development by providing assets that can be uploaded as Asset Loader additions to the Media Library and enqueued to either the public facing or admin environment.

The intent of this environment is to be used for lightweight additions to styles or DOM manipulation that is beyond the scope of what WordPress itself can manage inside the core block theme environment.

Entry points

For public facing style updates use:

  • /styles/public-additional-styles.scss for SCSS efforts
  • /scripts/public-additional-scripts.js for Javascript efforts

There are occasions when the changes made to public facing styles should also be replicated in the block editing environment. So for any admin side specific style updates use:

  • /styles/admin-additional-styles.scss

Build files

For watching changes and generating new builds on save:

npm run build:watch

For one off builds:

npm run build

Files from either of these commands will be found in /dist/assets/ โ€“ as noted above these files should then be uploaded to the Media Library and enqueued for Public or Admin use (or both) respectively. By default only styles are provided for enqueing on the admin side. You are safe to ignore any other files exported to the dist directory. It should also be noted that previous files uploaded and enqueued should be removed/deleted from the Media Library so as to not cause errors or unintended consequences.

Helper functions

Additional helpers Javascript functions are in /scripts/utils.js. Should you need to add your own helper functions, this file has been provided and is chunked into its own build file:

  • qs: a shorthand querySelect which returns the first element matching the given CSS selector within the given parent element
  • qsa: a shorthand querySelectAll that returns an actual array of all elements matching the given CSS selector within the given parent element
  • createElement: a better version of document.createElement that allows for creating an HTML element and passing in an object of attributes
  • addGlobalEventListener: a utility function that attaches an event listener to the given parent element and triggers the callback function only if the event target matches the given selector
  • findParentElementByClass: finds the closest ancestor element with the specified class name from the given element

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.