Compare commits

...

27 Commits

Author SHA1 Message Date
0b5e54faa6 Fix colours(fixes #31) 2025-05-14 19:21:01 -04:00
6d8b9d0e47 switch core to use @use(fixes #31) 2025-05-14 18:04:28 -04:00
9db11f3f97 Fix ending period. 2025-05-14 17:53:11 -04:00
df95905fe0 Fix for render issue for tabs 2025-04-22 15:25:41 -04:00
89870edaaf Make module definitions consistent 2025-04-03 07:42:09 -04:00
ca3f9970a9 Update tabs to allow for custom color on tab and top bar. 2025-02-04 16:55:15 -05:00
d5cbcb5807 Focusing the tab seems to have improved the reliability of the click happening. 2025-02-04 13:06:52 -05:00
a204f7fc98 Update core.scss.pug (and associated files) 2025-02-04 10:30:15 -05:00
c6e7b616f1 Fixes #27 Fixed css error max-contents > max-content 2025-02-01 09:56:49 -05:00
2a060106bc Remove workspace file 2025-02-01 09:53:56 -05:00
e2c05ac338 Updated git-ignore to ignore workspace 2025-02-01 09:43:27 -05:00
93800c2706 Provide mechanism to get tab click (Fixes #4) 2025-01-30 23:00:03 -05:00
67c857bbed Remove the alert in one click select 2025-01-30 19:24:11 -05:00
516b0fe4df Add intro to explain the project 2025-01-11 13:08:34 -05:00
b5e0061247 Add code to auto select tabs 2025-01-11 13:03:27 -05:00
a8cd90c349 Fixes #25 Javascript to redirect into the ds 2024-11-08 12:18:26 -05:00
be90329514 sublime-Workspace just changed 2024-10-18 23:21:30 -04:00
d64bb5e7a2 Readme addtiions 2024-10-18 23:20:01 -04:00
f842822915 Clean up lines from intersection observer testing. 2024-10-18 18:44:04 -04:00
c0aa93a3c1 Fixes #20 core.cookie.remove now sets the value and the date of the date object to null which deletes the cookie. 2024-10-18 18:39:38 -04:00
7dcc72d5a0 Fixes #24 - Expose oneClickSelect 2024-10-18 18:25:40 -04:00
f70d94ea67 Fixes #21 2024-10-18 18:19:40 -04:00
339e177ac4 Fixes #23 2024-10-18 09:28:55 -04:00
197e6f2f33 #20 should be fixed but needs testing 2024-10-02 10:07:51 -04:00
bcbe51e9a7 Fix error and reinitialize getcss function (reopens #14) 2024-09-23 11:40:09 -04:00
559552f218 Fixes #17 - styles not correct for colour cards when using text that is too large 2024-09-18 09:22:11 -04:00
2cd25ad7bd Fixes #18 2024-09-16 16:29:32 -04:00
23 changed files with 961 additions and 1691 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.DS_Store
ds2 core.sublime-workspace

View File

@ -1,4 +1,14 @@
# DS2 Core
# DS2-core
DS2-core is a lightweight PugJS-based framework for building design systems.
The design system compiles to mostly pure HTML, SCSS and JavaScript. There are a few enhanced parts that use PHP in order to handle non-critical tasks Zip files on the fly to collect component JavaScript and SCSS. PugJS is used because it can handle some of the automation such as creating includes making components extremely modular.
## Requirements
The requirements for ds2-core are pretty light. You'll want to be able to process [PugJS](https://pugjs.org/api/getting-started.html) (formerly Jade) and [SCSS](https://sass-lang.com/documentation/) -- and that's about it.
For our own design system, we use ds2-core with [Prepros](https://prepros.io) (which you can use the Free Unlimited Trial for, but why not splurge and spend the $30USD to support the developer and skip the nags). On MacOS, you could also use [CodeKit](https://codekitapp.com/).
Alternatively, if you have pre-processor pipelines for Pug and SCSS, which you can install using npm, or any other language you decide to pull in, you can use those to compile if that ends up being easier for you. The framework isn't too picky, so long as things go into the right place.
## "Installation"
@ -11,20 +21,23 @@ src/pg/core/download.php.pug | public
All other pug files should compile to from src/pg/ to a relative path of public/*
## Running the core
functions
### Callback functions
Callback functions can be used in
beforeArticleLoad - called before any patterns are started to load
success - called when loading a pattern is successful if the result is an HTTP 200
afterArticleLoad - called after any patterns are started to load
done - called when the ajax for any pattern is done, whether successful or not. This is a useful place to load any javascript initializations that pattern.
- beforeArticleLoad - called before any patterns have started to load
- success - called when loading a pattern is successful if the result is an HTTP 200
- afterArticleLoad - called after any patterns have started to load
- done - called when the ajax for any pattern is done, whether successful or not. This is a useful place to load any javascript initializations that pattern.
## About the content variable
## Creating an item
The content variable in \_config.pug defines your array of patterns. It is made up of the following attributes:
## The content object
The content variable in \/src\/pg\/_config.pug defines your array of patterns. It is made up of the following attributes:
- name - the hypenated name of the pattern
- status - this should be one of the statuses from your status array
- display - (optional) if present this will be displayed, as is, instead of the name
@ -49,6 +62,42 @@ In your design system implementation,
This will ensure that the .pug file will get processed and the .pp file will be handled as text will get compiled, but they should display correctly and remain in sync while maintaining the minimum number of files.
## Using core code with your own pattern documentation.
Using
---
Creating a new pattern
Begin by creating a folder within your strucutre to hold the pattern. Add the folder to your config file.
Generating css
You've likely created your component's css as an include file beginning with an underscore. create a second file named the same that includes any dependencies (such as breakpoints) that are required to generate your valid css.
You can now include the css in your pattern's index file.
Generating pug
Create a custom tool in prepros, give it a name such as "PP to Pug" set the input extension to .pp and the output extension to .pug and check Process Automatically . The command should be
Mac / Linux
cp {{input}} {{output}}
Windows
copy {{input}} {{output}}
Once you've added the tool, set the output to "relative path" and set the output extension to pug. For each .pp file you may have to check process automatically as it doesn't always identify the new extension.
You will now be able to include the .pp file in your pattern's index file while including the .pug file which will give a compiled version of your component's html.
---
## Troubleshooting
## Credits
This framework includes [PrismJS](https://prismjs.com/) for code syntax highlighting. PrismJS is released under the [MIT license](https://opensource.org/licenses/MIT)>
This framework includes [PrismJS](https://prismjs.com/) for code syntax highlighting. PrismJS is released under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -1,602 +0,0 @@
{
"auto_complete":
{
"selected_items":
[
[
"Quer",
"querySelectorAll"
],
[
"get",
"getAttribute"
],
[
"query",
"querySelectorAll"
],
[
"to",
"toContent"
],
[
"tos",
"toSentenceCase"
],
[
"sticky",
"sticky-note"
],
[
"back",
"background-color"
],
[
"setAttr",
"setAttributes"
],
[
"post",
"positionSticky"
],
[
"grid-",
"grid-column"
],
[
"of",
"offsetWidth"
],
[
"fun",
"function"
],
[
"grid-template",
"grid-template-columns"
],
[
"text",
"text-decoration"
],
[
"text-",
"text-decoration"
],
[
"grid-template-",
"grid-template-columns"
],
[
"bakc",
"background-color"
],
[
"copyco",
"copycolour"
],
[
"ar",
"article"
],
[
"toS",
"toSentenceCase"
],
[
"bacg",
"background-color"
],
[
"acc",
"accent-grey"
],
[
"_",
"_POST"
],
[
"json",
"json_encode"
],
[
"font",
"font-heading"
],
[
"border",
"border-radius"
],
[
"background-o",
"background-position"
],
[
"lang",
"language\tAttr"
],
[
"Emai",
"EMAIL_FOLDER"
],
[
"tem",
"template"
],
[
"G",
"GetParentFolderName"
],
[
"out",
"outFile"
],
[
"with",
"With"
],
[
"Write",
"WriteFile"
],
[
"File",
"FileExists"
],
[
"font-",
"font-weight"
],
[
"list-st",
"list-style-type"
],
[
"html",
"html5\tSimple HTML5 Boilerplate"
],
[
"backgroun",
"background-color"
],
[
"background-",
"background-color"
],
[
"place",
"place_content"
],
[
"string",
"stringify"
],
[
"cor",
"corpbiege"
],
[
"inner",
"innerWidth"
],
[
"program",
"programcontent"
],
[
"corp",
"corpgreen"
]
]
},
"buffers":
[
],
"build_system": "",
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 89.0,
"last_filter": "",
"selected_items":
[
[
"key",
"Preferences: Key Bindings"
],
[
"live",
"MarkdownLivePreview: Open Preview"
],
[
"markdown",
"MarkdownLivePreview: Open Settings"
],
[
"install",
"Package Control: Install Package"
],
[
"packages",
"Package Control: Discover Packages"
],
[
"Package Control: ",
"Package Control: Discover Packages"
],
[
"insta",
"Package Control: Install Package"
],
[
"Package Control: install",
"Package Control: Install Package"
],
[
"package",
"Package Control: Install Package"
],
[
"compare",
"Compare with..."
],
[
"install\t",
"Package Control: Install Package"
],
[
"list",
"Package Control: List Packages"
],
[
"jav",
"Set Syntax: JavaScript"
],
[
"diff",
"Set Syntax: Diff"
]
],
"width": 444.0
},
"console":
{
"height": 0.0,
"history":
[
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"expanded_folders":
[
"/Users/am/Desktop/ds2-core",
"/Users/am/Desktop/ds2-core/src",
"/Users/am/Desktop/ds2-core/src/pg",
"/Users/am/Desktop/ds2-core/src/pg/patterns",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core"
],
"file_history":
[
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/switch/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/sticky-note/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/layouts/breakpoints/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/layouts/header/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/layouts/tabs/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/tooltip/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/status/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/core/colours/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/core/_master-index.pug",
"/Users/am/Desktop/ds2-core/src/pg/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/_config.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/components/sticky-note-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/components/switch-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/components/tooltip-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/layouts/breakpoints-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/layouts/header-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/layouts/tabs-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/status-core/index.pug",
"/Users/am/Desktop/ds2-core/src/pg/patterns/colours-core/index.pug",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/sticky-note-core/_sticky-note.js",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/_tabs.js",
"/Users/am/Desktop/ds2 core/src/pg/_master-index.pug",
"/Users/am/Desktop/ds2 core/src/pg/_config.pug",
"/Users/am/Desktop/ds2 core/src/scss/scaffolding.scss",
"/Users/am/Desktop/ds2 core/src/pg/index.pug",
"/Users/am/Desktop/ds2 core/src/js/scaffolding.js",
"/Users/am/Desktop/ds2 core/src/js/_core.js",
"/Users/am/Desktop/ds2 core/public/assets/scaffolding-min.js",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/header-core/_header.pug",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/header-core/_header.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/header-core/header.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/tooltip-core/_tooltip.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/tooltip-core/tooltip.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/switch-core/_switch.js",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/sticky-note-core/sticky-note.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/components/sticky-note-core/_sticky-note.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/colours-core/index.pug",
"/Users/am/Desktop/ds2 core/src/pg/_color-samples.pug",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/tabs.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/breakpoints-core/_breakpoints.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/_tabs-jquery.js",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/index.pug",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/_tabs.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/tabs-core/_tabs.pug",
"/Users/am/Desktop/ds2 core/src/scss/_color-samples.scss",
"/Users/am/Desktop/ds2 core/src/js/_color-samples.js",
"/Users/am/Desktop/ds2 core/public/assets/scaffolding.css",
"/Users/am/Desktop/ds2 core/src/pg/patterns/status-core/_status.scss",
"/Users/am/Desktop/ds2 core/src/pg/patterns/status-core/index.pug",
"/Users/am/Desktop/ds2 core/src/pg/patterns/layouts/header-core/index.pug",
"/Users/am/Desktop/ds2 core/src/js/_geturlvars.js",
"/Users/am/Desktop/ds2 core/src/js/_core-cookies.js",
"/Users/am/Desktop/My DS2/src/js/scaffolding.js",
"/Users/am/Desktop/ds2 core/Readme.md",
"/Users/am/Desktop/My DS2/src/scss/_color-samples.scss",
"/Users/am/Desktop/My DS2/src/scss/scaffolding.scss",
"/Users/am/Desktop/My DS2/public/assets/scaffolding.css",
"/Users/am/Desktop/My DS2/src/pg/_config.pug",
"/Users/am/Desktop/My DS2/src/scss/_core.scss",
"/Users/am/Desktop/ds2 core/src/pg/_core.scss.pug",
"/Users/am/Desktop/My DS2/src/pg/_master-pattern.pug",
"/Users/am/Desktop/My DS2/src/pg/_color-samples.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/other-docs/status/index.pug",
"/Users/am/Desktop/My DS2/src/pg/_core.scss.pug",
"/Users/am/Desktop/My DS2/src/pg/_master-index.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/visual-design/spacing/index.pug",
"/Users/am/Desktop/statuses.pug",
"/Users/am/Desktop/My DS2/src/pg/index.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/sticky-note/_sticky-note.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/sticky-note/_sticky-note.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/sticky-note/index.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/index.pug",
"/Users/am/Desktop/My DS2/src/js/_oneClickSelect.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/_tabs.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/_tabs-module.js",
"/Users/am/Desktop/tabs-module-old.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/esc6 tabs.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/tabs-module.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/_tabs.scss",
"/Users/am/Desktop/My DS2/public/assets/scaffolding-min.js",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/tabs.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/sticky-note/sticky-note.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/text/index.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/other-docs/flex-box/_flex-box.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/other-docs/grid/_grid.scss",
"/Users/am/Desktop/my DS2/src/pg/_config.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/button/_button.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/text/_text.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/text/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/_form-fields.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/textarea/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/textarea/_textarea.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/button/button.css",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/form-fields.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/button/button.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/form-fields/button/index.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/text/text.pug",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/text/text.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/form-fields.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/progress-bar/_progress-bar.scss",
"/Users/am/Desktop/My DS2/src/pg/patterns/components/form-fields/index.pug",
"/Users/am/Desktop/my DS2/src/scss/scaffolding.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/sticky-note/_sticky-note.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/sticky-note/_sticky-note.js",
"/Users/am/Desktop/my DS2/src/js/scaffolding.js",
"/Users/am/Desktop/my DS2/src/pg/patterns/layouts/main-navigation/_main-navigation.js",
"/Users/am/Desktop/my DS2/src/pg/_core.scss.pug",
"/Users/am/Desktop/my DS2/public/assets/scaffolding.css",
"/Users/am/Desktop/My DS2/src/pg/patterns/layouts/tabs/_tabs.pug",
"/Users/am/Desktop/my DS2/src/pg/_color-samples.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/layouts/tabs/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/_spacing.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/typography/_content.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/spacing.scss",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/typography/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/site-identifiers/favicon-and-browser-tab/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/site-identifiers/monogram/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/switch/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/tooltip/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/link/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/components/progress-bar/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/layouts/main-navigation/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/layouts/breakpoints/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/notifications/index.pug",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/spacing.css",
"/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/colours/index.pug"
],
"find":
{
"height": 24.0
},
"find_in_files":
{
"height": 179.0,
"where_history":
[
"<open files>"
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"../core/_master-pattern.pug",
"../core",
"hide-deprecated",
"deprecated",
"ajx",
"console.log",
"setupStickies",
"document.querySelector",
"renderPatterns",
"xhr",
"xhttp",
"document.querySelector",
"classList",
"core.",
"innerHTML",
"core.",
"generateSCSS",
"showMessage(",
"core.showMessage",
"core.colours",
"core.colors",
"status-",
"header",
"status:",
"status",
"core: \"true\",",
"1rem",
"main-grid-4col",
"@include main-grid-4col;",
"components",
"layouts",
"alert",
"colour",
"main-grid",
"{\n\t\t\t\t\tname: \"header\",\n\t\t\t\t\tstatus: \"complete\",\n\t\t\t\t\tcore: true,\n\t\t\t\t}, ",
"colours",
"get.vars.",
"get.",
"colours.",
"cookie.get",
"cookie.set",
"cookie",
"function"
],
"highlight": false,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
"../../core/_master-pattern.pug",
"colors",
"core.cookie.get",
"core.cookie.set"
],
"reverse": false,
"scrollbar_highlights": true,
"show_context": true,
"use_buffer2": true,
"use_gitignore": true,
"whole_word": false,
"wrap": false
},
"groups":
[
{
"sheets":
[
]
}
],
"incremental_find":
{
"height": 24.0
},
"input":
{
"height": 209.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
]
],
"cols":
[
0.0,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.diff_views":
{
"height": 339.0
},
"output.exec":
{
"height": 147.0
},
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"project": "ds2 core.sublime-project",
"replace":
{
"height": 44.0
},
"save_all_on_build": false,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 500.0,
"last_filter": "",
"selected_items":
[
[
"",
"D:\\Projects\\apps\\Apps Website.sublime-project"
]
],
"width": 380.0
},
"select_symbol":
{
"height": 274.0,
"last_filter": "",
"selected_items":
[
],
"width": 592.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": false,
"show_open_files": true,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 254.0,
"status_bar_visible": true,
"template_settings":
{
}
}

View File

@ -1207,6 +1207,9 @@
"concat-js": {
"enable": false
},
"babel": {
"enable": true
},
"bundle-js": {
"enable": true,
"options": {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -287,23 +287,23 @@
<div class="tab-group" id="colors">
<div data-tab="css">
<pre class="language-css">:root {
--colour-blue: #2e51a1,
--colour-blue-l: #5c7abf,
--colour-blue-xl: #b2c3ec,
--colour-blue-d: #133176,
--colour-blue-xd: #031235,
--colour-blue: #2e51a1;
--colour-blue-l: #5c7abf;
--colour-blue-xl: #b2c3ec;
--colour-blue-d: #133176;
--colour-blue-xd: #031235;
--colour-grey: #7f7f7f,
--colour-grey-l: #b2b2b2,
--colour-grey-xl: #d8d8d8,
--colour-grey-xxl: #f0f0f0,
--colour-white: #fff,
--colour-page: #fff,
--colour-light: #fff,
--colour-grey-d: #4c4c4c,
--colour-grey-xd: #4c4c4c,
--colour-black: #000,
--colour-dark: #000,
--colour-grey: #7f7f7f;
--colour-grey-l: #b2b2b2;
--colour-grey-xl: #d8d8d8;
--colour-grey-xxl: #f0f0f0;
--colour-white: #fff;
--colour-page: #fff;
--colour-light: #fff;
--colour-grey-d: #4c4c4c;
--colour-grey-xd: #4c4c4c;
--colour-black: #000;
--colour-dark: #000;
}</pre>
</div>
<div data-tab="scss">

View File

@ -82,13 +82,17 @@ function flip(e) {
module.exports = {
init: (p = document) => {
p.querySelectorAll("[role='switch']").forEach((sw) => {
sw.innerHTML = "<span></span>";
sw.setAttribute("aria-checked", "false");
sw.setAttribute("tabindex", "0");
sw.addEventListener("click", flip, false);
sw.addEventListener("keypress", flip, false);
})
try {
p.querySelectorAll("[role='switch']").forEach((sw) => {
sw.innerHTML = "<span></span>";
sw.setAttribute("aria-checked", "false");
sw.setAttribute("tabindex", "0");
sw.addEventListener("click", flip, false);
sw.addEventListener("keypress", flip, false);
})
} catch (e) {
console.warn("Cannot initialise switches.", e);
}
}
}
</pre>

View File

@ -2,6 +2,13 @@
<html>
<head>
<title>Pattern</title>
<script>
let u = document.location.href.substring(0, document.location.href.search(/patterns/i));
let p = document.location.pathname.substring(document.location.pathname.search(/patterns/i));
p = p.replace(/\/$|\/index\.html/i, "").substring(9);
window.location = u + "?p=" + p;
</script>
</head>
<body data-prismjs-copy-timeout="1500">
<h2>What is it</h2>
@ -17,6 +24,14 @@
<p>Users should not need to see content of multiple tabs simultaneously and the user should be able to easily recognise where they are within the content. </p>
<h2>How to use it</h2>
<p>The structure of the tab set is defined in html. There are two forms supported. Adding a class of <code class="inline">.tab-group</code> to the container element will work in place of the <code class="inline">tabset</code> tag, and the tab panels can be defined using either <code class="inline">tab=""</code> or <code class="inline">data-tab=""</code>. Passing an optional element to the init function will initialise tabs within that element. </p>
<p>The tab initalize function now takes a new function parameter in the form of an third argument is an object that can take the following callbacks: </p>
<ul>
<li>altModifer (When the altKey is used)</li>
<li>shiftModifier (When the shift key is used)</li>
<li>metaModifier (When the Windows key or Apple key is used)</li>
</ul>
<p>You can use these callbacks to create a custom event to get the tab information. </p>
<p>Note: There is a new core function (core.getTabPath) that will generate the query string and url hash for use in DS2 Core. You may wish to update your scaffolding.js file to make use of this functionality. </p>
<tabset id="tabs">
<pre class="language-html" tab="html">
<tabset id="uniqueID">
@ -27,58 +42,7 @@
div(tab="[tab title]")
div(tab="[tab title]")
</pre>
<pre class="language-css" tab="css">tabset, .tab-group {
margin: 2rem 0 1rem 0;
}
tabset > ul, .tab-group > ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin: 0;
padding: 0;
}
tabset > ul li.separator, .tab-group > ul li.separator {
border-bottom: 1px solid #7f7f7f;
border-left: 1px solid #7f7f7f;
display: inline-block;
margin: 0.45rem 0 0 0;
width: 100%;
}
tabset .tab-hidden, .tab-group .tab-hidden {
display: none;
}
tabset [role=tab], .tab-group [role=tab] {
background-color: #FFF;
border-left: 1px solid #7f7f7f;
border-top: 1px solid #7f7f7f;
border-radius: 0.5rem 0.5rem 0 0;
cursor: pointer;
margin: 0;
display: inline;
padding: 1rem 1.5rem 0.14rem 1.5rem;
z-index: 2;
}
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
border-right: 1px solid #7f7f7f;
}
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
background-color: #f0f0f0;
border-bottom: 1px solid #7f7f7f;
}
tabset [role=tab] span, .tab-group [role=tab] span {
display: block;
margin: 0 0 0.5rem 0;
}
tabset [role=tabpanel], .tab-group [role=tabpanel] {
background-color: #FFF;
border: 1px solid #7f7f7f;
border-top: none;
padding: 1rem;
z-index: 1;
}
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
display: none;
}</pre>
<pre class="language-css" tab="css">.tab-group,tabset{margin:2rem 0 1rem 0}.tab-group>ul,tabset>ul{display:-webkit-box;display:-ms-flexbox;display:flex;margin:0;padding:0}.tab-group>ul li.separator,tabset>ul li.separator{border-bottom:1px solid #7f7f7f;border-left:1px solid #7f7f7f;display:inline-block;margin:0.45rem 0 0 0;width:100%}.tab-group .tab-hidden,tabset .tab-hidden{display:none}.tab-group [role=tab],tabset [role=tab]{background-color:#FFF;border-left:1px solid #7f7f7f;border-radius:0.5rem 0.5rem 0 0;border-top:1px solid #7f7f7f;color:#000;cursor:pointer;display:inline;margin:0;padding:1rem 1.5rem 0.14rem 1.5rem;z-index:2}.tab-group [role=tab]:last-of-type,tabset [role=tab]:last-of-type{border-right:1px solid #7f7f7f}.tab-group [role=tab]:not(.selected),tabset [role=tab]:not(.selected){background-color:#f0f0f0;border-bottom:1px solid #7f7f7f;color:#000}.tab-group [role=tab] span,tabset [role=tab] span{display:block;margin:0 0 0.5rem 0}.tab-group [role=tabpanel],tabset [role=tabpanel]{background-color:#FFF;border:1px solid #7f7f7f;border-top:#7f7f7f solid 1px;padding:1rem;z-index:1}.tab-group [role=tabpanel]:not(.open),tabset [role=tabpanel]:not(.open){display:none}</pre>
<div tab="scss">
<pre class="language-sass">@import "scss/core/tabs/_tabs";
@include tabs{
@ -89,8 +53,13 @@ tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
// Licensed under CC BY-SA 4.0
$tab-border: #7f7f7f !default;
$tab-panel-background-color: #FFF !default;
$tab-panel-top-border: #7f7f7f !default;
$tab-panel-top-border-width: 1px !default;
$tab-selected: #FFF !default;
$tab-selected-text: #000 !default;
$tab-notselected: #f0f0f0 !default;
$tab-notselected-text: #000 !default;
@mixin tabs {
tabset, .tab-group {
@ -116,11 +85,12 @@ $tab-notselected: #f0f0f0 !default;
[role="tab"] {
background-color: $tab-selected;
border-left: 1px solid $tab-border;
border-top: 1px solid $tab-border;
border-radius: .5rem .5rem 0 0;
border-top: 1px solid $tab-border;
color: $tab-selected-text;
cursor:pointer;
margin: 0;
display: inline;
margin: 0;
padding: 1rem 1.5rem .14rem 1.5rem;
z-index: 2;
@ -131,6 +101,7 @@ $tab-notselected: #f0f0f0 !default;
&:not(.selected) {
background-color: $tab-notselected;
border-bottom: 1px solid $tab-border;
color: $tab-notselected-text;
}
span {
@ -140,9 +111,9 @@ $tab-notselected: #f0f0f0 !default;
}
[role="tabpanel"] {
background-color: $tab-selected;
background-color: $tab-panel-background-color;
border: 1px solid $tab-border;
border-top: none;
border-top: $tab-panel-top-border solid $tab-panel-top-border-width;
padding: 1rem;
z-index: 1;
@ -150,7 +121,6 @@ $tab-notselected: #f0f0f0 !default;
display: none;
}
@content;
}
}
}</pre>
@ -169,8 +139,31 @@ const click = new MouseEvent('click', {
cancelable: true
});
export function init(p = document, s = true) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
const waitForElement = (selector) => {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
export function init(container = document, spacer = true, args = {}) {
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
const tabgroup = tabGroup.getAttribute("id");
@ -196,21 +189,29 @@ export function init(p = document, s = true) {
const ul = document.createElement('ul');
ul.setAttribute("role", "tablist");
ul.innerHTML = s != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
ul.innerHTML = spacer != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
tabGroup.insertBefore(ul, tabGroup.firstChild);
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
tab.addEventListener("click", () => {
const siblings = Array.from(tab.parentNode.children);
siblings.forEach(sibling => sibling.classList.remove("selected"));
tab.classList.add("selected");
tab.addEventListener("click", (e) => {
if (e.altKey && typeof args.altModifier == "function") {
args.altModifier(tab);
} else if (e.shiftKey && typeof args.shiftModifier == "function") {
args.shiftModifier(tab);
} else if (e.metaKey && typeof args.metaModifier == "function") {
args.metaModifier(tab);
} else {
const siblings = Array.from(tab.parentNode.children);
siblings.forEach(sibling => sibling.classList.remove("selected"));
tab.classList.add("selected");
const tabPanels = Array.from(tab.parentNode.parentNode.children)
.filter(child => child.getAttribute("role") === "tabpanel");
tabPanels.forEach(panel => panel.classList.remove("open"));
const tabPanels = Array.from(tab.parentNode.parentNode.children)
.filter(child => child.getAttribute("role") === "tabpanel");
tabPanels.forEach(panel => panel.classList.remove("open"));
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
}
});
@ -222,6 +223,15 @@ export function init(p = document, s = true) {
})
});
}
if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
waitForElement(document.location.hash).then((el) => {
el.scrollIntoView();
el.focus();
el.dispatchEvent(click);
});
}
});
}
</pre>

View File

@ -21,7 +21,7 @@ const font = {
size: 0
}
const copyColourFallback = (copyInfo, attr) => {
const copyFallback = (copyInfo, attr) => {
console.log("fallback")
var textArea = document.createElement('textarea');
textArea.value = copyInfo;
@ -71,22 +71,6 @@ const showMessage = (m, s) => {
}, 1000);
}
const oneClickSelect = (e, t = e.currentTarget) => {
// In here, "this" is the element
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(t);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(t);
range.select();
}
}
const getURLVars = () => {
var oResult = {};
if (location.search.length > 0) {
@ -145,12 +129,26 @@ module.exports = {
}
return "";
},
remove: (cnane) => {
setCookie(cname, "", -1);
remove: (cname) => {
module.exports.cookie.set(cname, null, new Date(null));
},
},
oneClickSelect: (e, t = e.currentTarget) => {
// In here, "this" is the element
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(t);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(t);
range.select();
}
},
colour: {
copy: (w, t) => {
let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w));
c = w == "var" ? `var(${c})` : c;
@ -159,10 +157,10 @@ module.exports = {
navigator.clipboard.writeText(c).then(function() {
showMessage(`Copied ${w}.`);
}, function(e) {
copyColourFallback(c,w);
copyFallback(c,w);
});
} else {
copyColourFallback(c, w);
copyFallback(c, w);
}
},
@ -178,9 +176,26 @@ module.exports = {
})
}
},
// getCSS: (el, prop, b = false) {
// return window.getComputedStyle(el, null).getPropertyValue(prop);
// },
getCSS: (el, prop, b = false) => {
return window.getComputedStyle(el, null).getPropertyValue(prop);
},
getTabPath: (t) => {
let url = window.location.toString();
url = url.indexOf("?") > 0 ? url.substring(0,url.indexOf("?")) : url;
url = `${url}?p=${t.closest("article").getAttribute("data-path")}#${t.getAttribute("id")}`
let type = "URL";
if (navigator.clipboard) {
navigator.clipboard.writeText(url).then(function() {
showMessage(`Copied ${type}.`);
}, function(e) {
copyFallback(url,type);
});
} else {
copyFallback(url, type);
}
},
init: (args = {}) => {
const url = getURLVars();
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
@ -192,11 +207,14 @@ module.exports = {
if (url.p == -1) {
document.querySelector("title").innerHTML = `${url.p.toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }`;
} else {
let theTitle = docuemnt.querySelector("article").getAttribute("data-name").toContent().toTitleCase();
if (docuemnt.querySelector("article").getAttribute("data-display") !== null) {
theTitle = docuemnt.querySelector("article").getAttribute("data-display")
let theTitle = document.querySelectorAll("article");
if (theTitle.length > 0) {
theTitle = theTitle[0].getAttribute("data-name").toContent().toTitleCase();
if (document.querySelector("article").getAttribute("data-display") !== null) {
theTitle = document.querySelector("article").getAttribute("data-display")
}
document.querySelector("title").innerHTML = `${theTitle} | ${ document.querySelector("title").getAttribute("data-site") }`
}
document.querySelector("title").innerHTML = `${theTitle} | ${ document.querySelector("title").getAttribute("data-site") }`
}
}
@ -208,10 +226,6 @@ module.exports = {
articles.forEach(article => {
let a = article.target;
// console.log("observing: ", { id: a.getAttribute("id"), intersecting: a.isIntersecting } )
// if (article.intersectionRatio > 0) {
// console.log("Is interesecting: ", { id: article.target.getAttribute("id"), intersecting: article.isIntersecting, ratio: article.intersectionRatio } )
if (article.isIntersecting == true) {
let path = a.getAttribute("data-path");
path = "patterns/" +
@ -252,7 +266,7 @@ module.exports = {
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
module.exports.oneClickSelect(e);
}
})

View File

@ -12,10 +12,12 @@ import * as stickynote from "../pg/patterns/core/sticky-note/_sticky-note.js";
import * as swtch from "../pg/patterns/core/switch/_switch.js";
import * as tabs from "../pg/patterns/core/tabs/_tabs.js";
// init core
// init c
core.init({
success: (a) => {
tabs.init(a);
tabs.init(a, true, {
shiftModifier: core.getTabPath,
});
swtch.init(a);
stickynote.init(a);
},
@ -24,6 +26,7 @@ core.init({
}
});
// deprecated switch handler
const flipInfoSwitch = (e, s = e.currentTarget) => {
@ -37,12 +40,10 @@ const flipInfoSwitch = (e, s = e.currentTarget) => {
break;
case "breakpoints" :
console.log("here")
core.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/");
document.querySelector("html").classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-breakpoints");
break;
}
}
// create a pure JS mouse click event

View File

@ -128,15 +128,15 @@
- function generateCSS(c, p) {
- let o = "";
- for (let i = 0; i < c.length; i++) {
- o += `\n\t--${p}-${c[i].name.toLowerCase()}: ${ color(c[i].color, "hex").toLowerCase() },\n`;
- o += `\n\t--${p}-${c[i].name.toLowerCase()}: ${ color(c[i].color, "hex").toLowerCase() };\n`;
- for (let ii = 0; ii < c[i].grad.l.length; ii++) {
- o += `\t--${p}-${c[i].grad.l[ii].n.toLowerCase()}: ${ color(c[i].grad.l[ii].c, "hex").toLowerCase() },\n`;
- o += `\t--${p}-${c[i].grad.l[ii].n.toLowerCase()}: ${ color(c[i].grad.l[ii].c, "hex").toLowerCase() };\n`;
- }
- for (let ii = 0; ii < c[i].grad.d.length; ii++) {
- o += `\t--${p}-${c[i].grad.d[ii].n.toLowerCase()}: ${ color(c[i].grad.d[ii].c, "hex").toLowerCase() },\n`;
- o += `\t--${p}-${c[i].grad.d[ii].n.toLowerCase()}: ${ color(c[i].grad.d[ii].c, "hex").toLowerCase() };\n`;
- }
- }
- return o;
- return o;
- }
if !colortxt

View File

@ -1,3 +1,5 @@
@use "../pg/patterns/core/breakpoints/breakpoints";
@mixin core-colour-samples {
#copystatus {
@ -36,14 +38,14 @@
gap: 1rem;
margin-bottom: 1rem;
@include break(-lg) {
@include breakpoints.break(-lg) {
display: grid;
grid-template-columns: repeat(2, 1fr);
max-width: 100%;
width: 100%;
}
@include break(-sm) {
@include breakpoints.break(-sm) {
grid-template-columns: auto;
width: 100%;
max-width: 100%;
@ -67,7 +69,7 @@
width: 20rem;
max-width: 318px;
@include break(-lg) {
@include breakpoints.break(-lg) {
width: 100%;
max-width: 100%;
}

View File

@ -37,6 +37,11 @@ html
head
title Pattern
script.
let u = document.location.href.substring(0, document.location.href.search(/patterns/i));
let p = document.location.pathname.substring(document.location.pathname.search(/patterns/i));
p = p.replace(/\/$|\/index\.html/i, "").substring(9);
window.location = u + "?p=" + p;
body(data-assetpath= assetpath data-prismjs-copy-timeout="1500")

View File

@ -5,270 +5,18 @@
This file is generates _core.scss using information in ../pg/_config.pug.
Please make your changes in your _config.pug file so that they are not
overwritten. \n*/\n\n\n`
| !{out}
include ../_config
include _colour-samples
include _core-colour-samples.scss
-
out +=`@mixin core-colour-samples {
#copystatus {
left: 50%;
position: absolute;
z-index: 100;
div {
border-radius: 1rem;
border: 1px solid green;
left: -50%;
padding: 1rem;
position: relative;
white-space: nowrap;
&::after {
clear: both;
content: " ";
display: block;
}
&.succeeded {
background-color: white;
border-color: black;
color: black;
}
&.failed {
background-color: white;
border-color: #f00;
color: #f00;
}
}
}
color-samples {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 1rem;
margin-bottom: 1rem;
@include break(-lg) {
display: grid;
grid-template-columns: repeat(2, 1fr);
max-width: 100%;
width: 100%;
}
@include break(-sm) {
grid-template-columns: auto;
width: 100%;
max-width: 100%;
}
color-sample {
align-items: center;
border-radius: .5rem;
border: 1px solid #CCC;
display: grid;
font-family: inherit;
gap: .5rem;
grid-template-areas: "name name name hex hex hex"
"name name name rgb rgb rgb"
"acc acc acc acc acc acc"
"lighter lighter lighter darker darker darker"
"notes notes notes notes notes notes";
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(2, 1.5rem) 10rem repeat(3, max-content); // 3rem repeat(2, 2rem) 1.5rem repeat(3, max-content);
padding: 1rem;
width: 20rem;
max-width: 318px;
@include break(-lg) {
width: 100%;
max-width: 100%;
}
name {
align-self: start;
font-size: 1.25rem;
grid-area: name;
span {
cursor: pointer;
}
}
rgb {
grid-area: rgb;
white-space: nowrap;
}
hex {
grid-area: hex;
white-space: nowrap;
}
> accessibility {
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
}
accessibility {
grid-area: acc;
grid-row: 3;
padding: .5rem 0;
display: grid;
gap: .5rem;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 2.5rem repeat(2, max-content);
.result {
align-items: center;
border-radius: .5rem;
display: grid;
grid-template-columns: repeat(2, 1fr);
border: 1px solid #ccc;
padding: 0 1rem;
text-align: center;
&.accwaa, &.accwaaa {
background-color: white;
color: black;
}
&.accbaa, &.accbaaa {
background-color: black;
color: white;
}
span:nth-child(2) {
font-size: 2rem;
}
}
.aa, .aaa {
align-self: center;
display: block;
font-size: .75rem;
}
.acchb {
grid-column: 2;
}
.acchb, .acchw {
display: grid;
grid-tempate-columns: auto;
grid-template-rows: repeat(2, max-content);
align-self: start;
text-align: center;
padding: 0;
span {
grid-row: 1;
grid-column: 1 / -1;
font-size: .9rem;
}
small {
text-align: center;
grid-row: 2;
grid-column: 1 / -1;
font-size: .75rem;
}
}
}
sample-block {
align-self: start;
grid-column: span 3;
grid-row: 4;
color-pill {
display: grid;
grid-gap: .5rem;
grid-template-columns: 20px max-content auto;
:nth-child(1) {
align-self: center;
border-radius: 5px;
border: 1px solid #CCC;
display: inline-block;
height: 10px;
width: 20px;
}
span {
cursor: pointer;
.tooltip-tc {
padding: .5rem;
width: 20rem;
max-width: 318px;
height: 10.5rem;
display: grid;
gap: .5rem;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, max-content);
.result {
align-items: center;
border-radius: .5rem;
display: grid;
grid-template-columns: repeat(2, 1fr);
border: 1px solid #ccc;
padding: 0 1rem;
text-align: center;
&.accwaa, &.accwaaa {
background-color: white;
color: black;
}
&.accbaa, &.accbaaa {
background-color: black;
color: white;
}
span{ border: none;
&:nth-child(2) {
font-size: 2rem;
}
}
}
.aa, .aaa {
align-self: center;
display: block;
font-size: .75rem;
}
.acchb {
grid-column: 2;
}
.acchb, .acchw {
border: none;
display: block;
width: 100%;
place-self: stretch;
span {
border: none;
font-size: .9rem;
width: 100%;
&::after, &::before {
display: none;
}
}
small {
font-size: .75rem;
text-align: center;
}
}
}
}
}
}
notes {
border-top: 1px solid #ccc;
grid-column: 1 / -1;
padding-top: .5rem;
}
}
}
}`
- out += `\n\n//colour tokens\n$${colorpfx}: (`
- out = `\n\n//colour tokens\n$${colorpfx}: (`
each val in generateColourToken
- out += generateSCSS(eval(val), colorpfx)
//- var scss = $colors
| !{generateSCSS(eval(val), colorpfx)}

View File

@ -95,37 +95,39 @@ const calculateStickyPosition = (s) => {
}
}
export function init(p = document){
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
p.querySelectorAll("sticky-note").forEach((s) => {
if (s.querySelectorAll("svg").length == 0) {
let wrapper = document.createElement("sticky-note-wrapper");
s.parentNode.insertBefore(wrapper, s);
wrapper.appendChild(s);
s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
s.innerHTML = `<div><svg width='0' height='0'><defs><clipPath id='stickyClip' clipPathUnits='objectBoundingBox'><path d='M 0 0 Q 0 0.69, 0.03 0.96 0.03 0.96, 1 0.96 Q 0.96 0.69, 0.96 0 0.96 0, 0 0' stroke-linejoin='round' stroke-linecap='square' /></clipPath></defs></svg></div><div><div>${s.innerHTML}</div></div>`;
}
calculateStickyPosition(s);
drag(s);
s.ondblclick = (e) => {
if (e.ctrlKey) {
calculateStickyPosition(s);
} else {
// add one click select
}
}
})
window.onresize = () => {
module.exports = {
init: (p = document) => {
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
let stickies = p.querySelectorAll("sticky-note");
stickies.forEach((s) => {
p.querySelectorAll("sticky-note").forEach((s) => {
if (s.querySelectorAll("svg").length == 0) {
let wrapper = document.createElement("sticky-note-wrapper");
s.parentNode.insertBefore(wrapper, s);
wrapper.appendChild(s);
s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
s.innerHTML = `<div><svg width='0' height='0'><defs><clipPath id='stickyClip' clipPathUnits='objectBoundingBox'><path d='M 0 0 Q 0 0.69, 0.03 0.96 0.03 0.96, 1 0.96 Q 0.96 0.69, 0.96 0 0.96 0, 0 0' stroke-linejoin='round' stroke-linecap='square' /></clipPath></defs></svg></div><div><div>${s.innerHTML}</div></div>`;
}
calculateStickyPosition(s);
});
drag(s);
s.ondblclick = (e) => {
if (e.ctrlKey) {
calculateStickyPosition(s);
} else {
// add one click select
}
}
})
window.onresize = () => {
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
let stickies = p.querySelectorAll("sticky-note");
stickies.forEach((s) => {
calculateStickyPosition(s);
});
}
}
}

View File

@ -15,12 +15,16 @@ function flip(e) {
module.exports = {
init: (p = document) => {
p.querySelectorAll("[role='switch']").forEach((sw) => {
sw.innerHTML = "<span></span>";
sw.setAttribute("aria-checked", "false");
sw.setAttribute("tabindex", "0");
sw.addEventListener("click", flip, false);
sw.addEventListener("keypress", flip, false);
})
try {
p.querySelectorAll("[role='switch']").forEach((sw) => {
sw.innerHTML = "<span></span>";
sw.setAttribute("aria-checked", "false");
sw.setAttribute("tabindex", "0");
sw.addEventListener("click", flip, false);
sw.addEventListener("keypress", flip, false);
})
} catch (e) {
console.warn("Cannot initialise switches.", e);
}
}
}

View File

@ -9,8 +9,31 @@ const click = new MouseEvent('click', {
cancelable: true
});
export function init(p = document, s = true) {
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
const waitForElement = (selector) => {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
export function init(container = document, spacer = true, args = {}) {
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
if (tabGroup.querySelector("[role=tablist]") === null) {
const tabgroup = tabGroup.getAttribute("id");
@ -28,7 +51,8 @@ export function init(p = document, s = true) {
tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`);
tabPanel.appendChild(child.cloneNode(true));
child.parentNode.replaceChild(tabPanel, child);
tablist += `<li tabindex="0" role="tab" ${tablist === "" ? "class='selected'" : ""} id="tab-${tabgroup}-${tabID}"><span>${tab}</span></li>`;
let cls = tablist === "" ? "class='selected'" : "";
tablist += `<li tabindex="0" role="tab" ${cls}="" id="tab-${tabgroup}-${tabID}"><span>${tab}</span></li>`;
} else {
child.classList.add("tab-hidden");
}
@ -36,21 +60,29 @@ export function init(p = document, s = true) {
const ul = document.createElement('ul');
ul.setAttribute("role", "tablist");
ul.innerHTML = s != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
ul.innerHTML = spacer != true ? `${tablist}` : `${tablist}<li role="separator" class="separator"></li>`;
tabGroup.insertBefore(ul, tabGroup.firstChild);
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
tab.addEventListener("click", () => {
const siblings = Array.from(tab.parentNode.children);
siblings.forEach(sibling => sibling.classList.remove("selected"));
tab.classList.add("selected");
tab.addEventListener("click", (evt) => {
if (evt.altKey && typeof args.altModifier == "function") {
args.altModifier(tab, evt);
} else if (evt.shiftKey && typeof args.shiftModifier == "function") {
args.shiftModifier(tab, evt);
} else if (evt.metaKey && typeof args.metaModifier == "function") {
args.metaModifier(tab, evt);
} else {
const siblings = Array.from(tab.parentNode.children);
siblings.forEach(sibling => sibling.classList.remove("selected"));
tab.classList.add("selected");
const tabPanels = Array.from(tab.parentNode.parentNode.children)
.filter(child => child.getAttribute("role") === "tabpanel");
tabPanels.forEach(panel => panel.classList.remove("open"));
const tabPanels = Array.from(tab.parentNode.parentNode.children)
.filter(child => child.getAttribute("role") === "tabpanel");
tabPanels.forEach(panel => panel.classList.remove("open"));
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
document.getElementById(tabPanelId).classList.add("open");
}
});
@ -62,5 +94,13 @@ export function init(p = document, s = true) {
})
});
}
if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
waitForElement(document.location.hash).then((el) => {
el.scrollIntoView();
el.focus();
el.dispatchEvent(click);
});
}
});
}
}

View File

@ -2,8 +2,13 @@
// Licensed under CC BY-SA 4.0
$tab-border: #7f7f7f !default;
$tab-panel-background-color: #FFF !default;
$tab-panel-top-border: #7f7f7f !default;
$tab-panel-top-border-width: 1px !default;
$tab-selected: #FFF !default;
$tab-selected-text: #000 !default;
$tab-notselected: #f0f0f0 !default;
$tab-notselected-text: #000 !default;
@mixin tabs {
tabset, .tab-group {
@ -29,11 +34,12 @@ $tab-notselected: #f0f0f0 !default;
[role="tab"] {
background-color: $tab-selected;
border-left: 1px solid $tab-border;
border-top: 1px solid $tab-border;
border-radius: .5rem .5rem 0 0;
border-top: 1px solid $tab-border;
color: $tab-selected-text;
cursor:pointer;
margin: 0;
display: inline;
margin: 0;
padding: 1rem 1.5rem .14rem 1.5rem;
z-index: 2;
@ -44,6 +50,7 @@ $tab-notselected: #f0f0f0 !default;
&:not(.selected) {
background-color: $tab-notselected;
border-bottom: 1px solid $tab-border;
color: $tab-notselected-text;
}
span {
@ -53,9 +60,9 @@ $tab-notselected: #f0f0f0 !default;
}
[role="tabpanel"] {
background-color: $tab-selected;
background-color: $tab-panel-background-color;
border: 1px solid $tab-border;
border-top: none;
border-top: $tab-panel-top-border solid $tab-panel-top-border-width;
padding: 1rem;
z-index: 1;
@ -63,7 +70,6 @@ $tab-notselected: #f0f0f0 !default;
display: none;
}
@content;
}
}
}

View File

@ -22,6 +22,15 @@ block content
+h(2)
p The structure of the tab set is defined in html. There are two forms supported. Adding a class of #[code.inline .tab-group] to the container element will work in place of the #[code.inline tabset] tag, and the tab panels can be defined using either #[code.inline tab=""] or #[code.inline data-tab=""]. Passing an optional element to the init function will initialise tabs within that element.
p The tab initalize function now takes a new function parameter in the form of an third argument is an object that can take the following callbacks:
ul
li altModifer (When the altKey is used)
li shiftModifier (When the shift key is used)
li metaModifier (When the Windows key or Apple key is used)
p You can use these callbacks to create a custom event to get the tab information.
p Note: There is a new core function (core.getTabPath) that will generate the query string and url hash for use in DS2 Core. You may wish to update your scaffolding.js file to make use of this functionality.
tabset#tabs
pre.language-html(tab="html")

View File

@ -1,52 +1 @@
tabset, .tab-group {
margin: 2rem 0 1rem 0;
}
tabset > ul, .tab-group > ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin: 0;
padding: 0;
}
tabset > ul li.separator, .tab-group > ul li.separator {
border-bottom: 1px solid #7f7f7f;
border-left: 1px solid #7f7f7f;
display: inline-block;
margin: 0.45rem 0 0 0;
width: 100%;
}
tabset .tab-hidden, .tab-group .tab-hidden {
display: none;
}
tabset [role=tab], .tab-group [role=tab] {
background-color: #FFF;
border-left: 1px solid #7f7f7f;
border-top: 1px solid #7f7f7f;
border-radius: 0.5rem 0.5rem 0 0;
cursor: pointer;
margin: 0;
display: inline;
padding: 1rem 1.5rem 0.14rem 1.5rem;
z-index: 2;
}
tabset [role=tab]:last-of-type, .tab-group [role=tab]:last-of-type {
border-right: 1px solid #7f7f7f;
}
tabset [role=tab]:not(.selected), .tab-group [role=tab]:not(.selected) {
background-color: #f0f0f0;
border-bottom: 1px solid #7f7f7f;
}
tabset [role=tab] span, .tab-group [role=tab] span {
display: block;
margin: 0 0 0.5rem 0;
}
tabset [role=tabpanel], .tab-group [role=tabpanel] {
background-color: #FFF;
border: 1px solid #7f7f7f;
border-top: none;
padding: 1rem;
z-index: 1;
}
tabset [role=tabpanel]:not(.open), .tab-group [role=tabpanel]:not(.open) {
display: none;
}
.tab-group,tabset{margin:2rem 0 1rem 0}.tab-group>ul,tabset>ul{display:-webkit-box;display:-ms-flexbox;display:flex;margin:0;padding:0}.tab-group>ul li.separator,tabset>ul li.separator{border-bottom:1px solid #7f7f7f;border-left:1px solid #7f7f7f;display:inline-block;margin:0.45rem 0 0 0;width:100%}.tab-group .tab-hidden,tabset .tab-hidden{display:none}.tab-group [role=tab],tabset [role=tab]{background-color:#FFF;border-left:1px solid #7f7f7f;border-radius:0.5rem 0.5rem 0 0;border-top:1px solid #7f7f7f;color:#000;cursor:pointer;display:inline;margin:0;padding:1rem 1.5rem 0.14rem 1.5rem;z-index:2}.tab-group [role=tab]:last-of-type,tabset [role=tab]:last-of-type{border-right:1px solid #7f7f7f}.tab-group [role=tab]:not(.selected),tabset [role=tab]:not(.selected){background-color:#f0f0f0;border-bottom:1px solid #7f7f7f;color:#000}.tab-group [role=tab] span,tabset [role=tab] span{display:block;margin:0 0 0.5rem 0}.tab-group [role=tabpanel],tabset [role=tabpanel]{background-color:#FFF;border:1px solid #7f7f7f;border-top:#7f7f7f solid 1px;padding:1rem;z-index:1}.tab-group [role=tabpanel]:not(.open),tabset [role=tabpanel]:not(.open){display:none}

View File

@ -10,6 +10,8 @@
*/
@use "../pg/patterns/core/breakpoints/breakpoints";
@mixin core-colour-samples {
#copystatus {
@ -48,14 +50,14 @@
gap: 1rem;
margin-bottom: 1rem;
@include break(-lg) {
@include breakpoints.break(-lg) {
display: grid;
grid-template-columns: repeat(2, 1fr);
max-width: 100%;
width: 100%;
}
@include break(-sm) {
@include breakpoints.break(-sm) {
grid-template-columns: auto;
width: 100%;
max-width: 100%;
@ -79,7 +81,7 @@
width: 20rem;
max-width: 318px;
@include break(-lg) {
@include breakpoints.break(-lg) {
width: 100%;
max-width: 100%;
}

View File

@ -1,4 +1,4 @@
/*
/* ----------------------------------------------------------
* Variables
*/
@ -15,16 +15,19 @@ $tooltip-dark-allow: false;
// We recommend explicitly using the underscore when referring to pattern scss
// as you may have also created a version that compiles to css to display in
// your pattern.
@import "core";
@import "../pg/patterns/core/sticky-note/_sticky-note";
@import "../pg/patterns/core/switch/_switch";
@import "../pg/patterns/core/tooltip/_tooltip";
@import "../pg/patterns/core/breakpoints/_breakpoints";
@import "../pg/patterns/core/header/_header";
@import "../pg/patterns/core/tabs/_tabs";
@import "../pg/patterns/core/status/_status";
@use "core";
@use "../../node_modules/prismjs/themes/prism";
@use "../../node_modules/prismjs/plugins/toolbar/prism-toolbar";
@use "../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers";
@use "../pg/patterns/core/sticky-note/_sticky-note";
@use "../pg/patterns/core/switch/_switch";
@use "../pg/patterns/core/tooltip/_tooltip";
@use "../pg/patterns/core/breakpoints/_breakpoints";
@use "../pg/patterns/core/header/_header";
@use "../pg/patterns/core/tabs/_tabs";
@use "../pg/patterns/core/status/_status";
use
* {
box-sizing: border-box;
}
@ -32,19 +35,19 @@ $tooltip-dark-allow: false;
html {
font-family: $font-body;
font-size: $font-size;
@include break(-md) {
@include breakpoints.break(-md) {
font-size: calc($font-size + 2pt);
}
&.show-breakpoints {
@include breakpoint-debug;
@include breakpoints.breakpoint-debug;
}
}
@include core-colour-samples;
@include core.core-colour-samples;
@include tooltip;
@include sticky-note;
@include status;
@include tooltip.tooltip;
@include sticky-note.sticky-note;
@include status.status;
article[data-status=deprecated]:not(.show-deprecated) {
display: none;
@ -65,7 +68,7 @@ body {
margin: 0 auto;
width: 100vw;
@include header;
@include header.header;
nav {
background-color: var(--colour-blue);
@ -84,7 +87,7 @@ body {
color: var(--colour-white);
text-decoration: none;
}
@include break(md-) {
@include breakpoints.break(md-) {
display: initial;
}
}
@ -98,7 +101,7 @@ body {
grid-row: 3;
grid-template-columns: auto repeat(2, max-content);
text-align: right;
@include switch;
@include switch.switch;
label {
text-align: left;;
}
@ -109,7 +112,7 @@ body {
grid-column: 1 / -1;
grid-row: 4;
@include break(-md) {
@include breakpoints.break(-md) {
grid-row: 3;
padding: 0;
}
@ -117,7 +120,7 @@ body {
@supports(grid-area: auto) {
display: grid;
grid-template-columns: 1rem repeat(2, auto) 1rem;
@include break(md-) {
@include breakpoints.break(md-) {
grid-template-columns: auto repeat(2, 22rem) auto;
}
}
@ -135,7 +138,7 @@ body {
display: none;
}
@include tabs {
@include tabs.tabs {
pre {
background-color: var(--colour-black-5);
font-size: .8rem;
@ -150,15 +153,12 @@ body {
display: grid;
grid-gap: .5rem;
grid-template-columns: max-content auto;
@include switch;
@include switch.switch;
}
}
}
}
}
// keep your prism modules
@import "../../node_modules/prismjs/themes/prism";
@import "../../node_modules/prismjs/plugins/toolbar/prism-toolbar";
@import "../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers";