Skip to content

Commit be0622e

Browse files
committed
docs: update theme
1 parent da5ddd5 commit be0622e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+621
-638
lines changed

docs/assets/js/application.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/assets/js/code-examples.js

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
/*!
66
* JavaScript for Bootstrap's docs (https://getcoreui.com/)
7-
* Copyright 2011-2022 The Bootstrap Authors
8-
* Copyright 2011-2022 Twitter, Inc.
7+
* Copyright 2011-2023 The Bootstrap Authors
98
* Licensed under the Creative Commons Attribution 3.0 Unported License.
109
* For details, see https://creativecommons.org/licenses/by/3.0/.
1110
*/
@@ -14,51 +13,80 @@
1413

1514
(() => {
1615
'use strict'
16+
1717
// Insert copy to clipboard button before .highlight
18-
const btnHtml =
19-
'<div class="docs-clipboard"><button type="button" class="btn-clipboard btn btn-ghost-primary" title="Copy to clipboard"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><polygon fill="var(--ci-primary-color, currentColor)" points="408 432 376 432 376 464 112 464 112 136 144 136 144 104 80 104 80 496 408 496 408 432" class="ci-primary"/><path fill="var(--ci-primary-color, currentColor)" d="M176,16V400H496V153.373L358.627,16ZM464,368H208V48H312V200H464Zm0-200H344V48h1.372L464,166.627Z" class="ci-primary"/></svg></button></div>'
20-
document.querySelectorAll('div.highlight').forEach(element => {
21-
element.insertAdjacentHTML('beforebegin', btnHtml)
22-
})
18+
const btnTitle = 'Copy to clipboard'
19+
const btnEdit = 'Edit on StackBlitz'
2320

24-
document.querySelectorAll('.btn-clipboard').forEach(btn => {
25-
const tooltipBtn = new coreui.Tooltip(btn)
21+
const btnHtml = [
22+
'<div class="docs-code-snippet">',
23+
' <div class="docs-clipboard">',
24+
' <button type="button" class="btn-clipboard">',
25+
' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16">',
26+
' <polygon fill="var(--ci-primary-color, currentColor)" points="408 432 376 432 376 464 112 464 112 136 144 136 144 104 80 104 80 496 408 496 408 432" class="ci-primary"/>',
27+
' <path fill="var(--ci-primary-color, currentColor)" d="M176,16V400H496V153.373L358.627,16ZM464,368H208V48H312V200H464Zm0-200H344V48h1.372L464,166.627Z" class="ci-primary"/>',
28+
' </svg>',
29+
' </button>',
30+
' </div>',
31+
'</div>'
32+
].join('')
2633

27-
btn.addEventListener('mouseleave', () => {
28-
// Explicitly hide tooltip, since after clicking it remains
29-
// focused (as it's a button), so tooltip would otherwise
30-
// remain visible until focus is moved away
31-
tooltipBtn.hide()
34+
// Wrap programmatically code blocks and add copy btn.
35+
document.querySelectorAll('.highlight')
36+
.forEach(element => {
37+
if (!element.closest('.docs-example-snippet')) { // Ignore examples made be shortcode
38+
element.insertAdjacentHTML('beforebegin', btnHtml)
39+
element.previousElementSibling.append(element)
40+
}
3241
})
33-
})
42+
43+
/**
44+
*
45+
* @param {string} selector
46+
* @param {string} title
47+
*/
48+
function snippetButtonTooltip(selector, title) {
49+
document.querySelectorAll(selector).forEach(btn => {
50+
coreui.Tooltip.getOrCreateInstance(btn, { title })
51+
})
52+
}
53+
54+
snippetButtonTooltip('.btn-clipboard', btnTitle)
55+
snippetButtonTooltip('.btn-edit', btnEdit)
3456

3557
const clipboard = new ClipboardJS('.btn-clipboard', {
36-
target(trigger) {
37-
return trigger.parentNode.nextElementSibling
38-
}
58+
target: trigger => trigger.closest('.docs-code-snippet').querySelector('.highlight'),
59+
text: trigger => trigger.closest('.docs-code-snippet').querySelector('.highlight').textContent.trimEnd()
3960
})
4061

41-
clipboard.on('success', e => {
42-
const tooltipBtn = coreui.Tooltip.getInstance(e.trigger)
62+
clipboard.on('success', event => {
63+
// const iconFirstChild = event.trigger.querySelector('.bi').firstElementChild
64+
const tooltipBtn = coreui.Tooltip.getInstance(event.trigger)
65+
// const namespace = 'http://www.w3.org/1999/xlink'
66+
// const originalXhref = iconFirstChild.getAttributeNS(namespace, 'href')
67+
// const originalTitle = event.trigger.title
4368

44-
e.trigger.setAttribute('data-coreui-original-title', 'Copied!')
45-
tooltipBtn.show()
69+
tooltipBtn.setContent({ '.tooltip-inner': 'Copied!' })
70+
event.trigger.addEventListener('hidden.coreui.tooltip', () => {
71+
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
72+
}, { once: true })
73+
event.clearSelection()
74+
// iconFirstChild.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
4675

47-
e.trigger.setAttribute('data-coreui-original-title', 'Copy to clipboard')
48-
e.clearSelection()
76+
// setTimeout(() => {
77+
// iconFirstChild.setAttributeNS(namespace, 'href', originalXhref)
78+
// event.trigger.title = originalTitle
79+
// }, 2000)
4980
})
5081

5182
clipboard.on('error', event => {
5283
const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
5384
const fallbackMsg = `Press ${modifierKey}C to copy`
5485
const tooltipBtn = coreui.Tooltip.getInstance(event.trigger)
5586

56-
event.trigger.setAttribute('data-coreui-original-title', fallbackMsg)
57-
tooltipBtn.show()
58-
59-
event.trigger.setAttribute(
60-
'data-coreui-original-title',
61-
'Copy to clipboard'
62-
)
87+
tooltipBtn.setContent({ '.tooltip-inner': fallbackMsg })
88+
event.trigger.addEventListener('hidden.coreui.tooltip', () => {
89+
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
90+
}, { once: true })
6391
})
6492
})()

docs/assets/js/snippets.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// ++++++++++++++++++++++++++++++++++++++++++
66

77
/*!
8-
* JavaScript for Bootstrap's docs (https://getbootstrap.com/)
9-
* Copyright 2011-2022 The Bootstrap Authors
10-
* Copyright 2011-2022 Twitter, Inc.
8+
* JavaScript for CoreUI's docs (https://coreui.io/)
9+
* Copyright 2023 creativeLabs Lukasz Holeczek
1110
* Licensed under the Creative Commons Attribution 3.0 Unported License.
1211
* For details, see https://creativecommons.org/licenses/by/3.0/.
1312
*/
@@ -20,7 +19,7 @@
2019
// --------
2120
// Tooltips
2221
// --------
23-
// Instanciate all tooltips in a docs or StackBlitz page
22+
// Instantiate all tooltips in a docs or StackBlitz
2423
document.querySelectorAll('[data-coreui-toggle="tooltip"]')
2524
.forEach(tooltip => {
2625
new coreui.Tooltip(tooltip)
@@ -29,7 +28,7 @@
2928
// --------
3029
// Popovers
3130
// --------
32-
// Instanciate all popovers in a docs or StackBlitz page
31+
// Instantiate all popovers in docs or StackBlitz
3332
document.querySelectorAll('[data-coreui-toggle="popover"]')
3433
.forEach(popover => {
3534
new coreui.Popover(popover)
@@ -50,7 +49,7 @@
5049
})
5150
}
5251

53-
// Instanciate all toasts in a docs page only
52+
// Instantiate all toasts in docs pages only
5453
document.querySelectorAll('.docs-example .toast')
5554
.forEach(toastNode => {
5655
const toast = new coreui.Toast(toastNode, {
@@ -60,24 +59,26 @@
6059
toast.show()
6160
})
6261

63-
// Instanciate all toasts in a docs page only
62+
// Instantiate all toasts in docs pages only
63+
// js-docs-start live-toast
6464
const toastTrigger = document.getElementById('liveToastBtn')
6565
const toastLiveExample = document.getElementById('liveToast')
66+
6667
if (toastTrigger) {
68+
const toastCoreUI = coreui.Toast.getOrCreateInstance(toastLiveExample)
6769
toastTrigger.addEventListener('click', () => {
68-
const toast = new coreui.Toast(toastLiveExample)
69-
70-
toast.show()
70+
toastCoreUI.show()
7171
})
7272
}
73+
// js-docs-end live-toast
7374

7475
// -------------------------------
7576
// Alerts
7677
// -------------------------------
77-
// Used in 'Show live toast' example in docs or StackBlitz
78-
const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
79-
const alertTrigger = document.getElementById('liveAlertBtn')
78+
// Used in 'Show live alert' example in docs or StackBlitz
8079

80+
// js-docs-start live-alert
81+
const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
8182
const appendAlert = (message, type) => {
8283
const wrapper = document.createElement('div')
8384
wrapper.innerHTML = [
@@ -90,19 +91,32 @@
9091
alertPlaceholder.append(wrapper)
9192
}
9293

94+
const alertTrigger = document.getElementById('liveAlertBtn')
9395
if (alertTrigger) {
9496
alertTrigger.addEventListener('click', () => {
9597
appendAlert('Nice, you triggered this alert message!', 'success')
9698
})
9799
}
100+
// js-docs-end live-alert
101+
102+
// --------
103+
// Carousels
104+
// --------
105+
// Instantiate all non-autoplaying carousels in docs or StackBlitz
106+
document.querySelectorAll('.carousel:not([data-coreui-ride="carousel"])')
107+
.forEach(carousel => {
108+
coreui.Carousel.getOrCreateInstance(carousel)
109+
})
98110

99111
// -------------------------------
100112
// Checks & Radios
101113
// -------------------------------
102114
// Indeterminate checkbox example in docs and StackBlitz
103115
document.querySelectorAll('.docs-example-indeterminate [type="checkbox"]')
104116
.forEach(checkbox => {
105-
checkbox.indeterminate = true
117+
if (checkbox.id.includes('Indeterminate')) {
118+
checkbox.indeterminate = true
119+
}
106120
})
107121

108122
// -------------------------------
@@ -120,13 +134,16 @@
120134
// Modal
121135
// -------------------------------
122136
// Modal 'Varying modal content' example in docs and StackBlitz
137+
// js-docs-start varying-modal-content
123138
const exampleModal = document.getElementById('exampleModal')
124139
if (exampleModal) {
125140
exampleModal.addEventListener('show.coreui.modal', event => {
126141
// Button that triggered the modal
127142
const button = event.relatedTarget
128143
// Extract info from data-coreui-* attributes
129144
const recipient = button.getAttribute('data-coreui-whatever')
145+
// If necessary, you could initiate an Ajax request here
146+
// and then do the updating in a callback.
130147

131148
// Update the modal's content.
132149
const modalTitle = exampleModal.querySelector('.modal-title')
@@ -136,6 +153,7 @@
136153
modalBodyInput.value = recipient
137154
})
138155
}
156+
// js-docs-end varying-modal-content
139157

140158
// -------------------------------
141159
// Offcanvas

docs/assets/scss/_ads.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
@include font-size(.8125rem);
1515
line-height: 1.4;
1616
text-align: left;
17-
background-color: $gray-100;
17+
background-color: var(--cui-tertiary-bg);
1818

1919
a {
20-
color: $gray-800;
20+
color: var(--cui-body-color);
2121
text-decoration: none;
2222
}
2323

@@ -34,5 +34,5 @@
3434
.carbon-poweredby {
3535
display: block;
3636
margin-top: .75rem;
37-
color: $gray-700 !important;
37+
color: var(--cui-body-color) !important;
3838
}

docs/assets/scss/_buttons.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Buttons
2+
//
3+
// Custom buttons for the docs.
4+
5+
// scss-docs-start btn-css-vars-example
6+
.btn-cd-primary {
7+
--cui-btn-font-weight: 600;
8+
--cui-btn-color: var(--cui-white);
9+
--cui-btn-bg: var(--cd-violet-bg);
10+
--cui-btn-border-color: var(--cd-violet-bg);
11+
--cui-btn-hover-color: var(--cui-white);
12+
--cui-btn-hover-bg: #{shade-color($cd-violet, 10%)};
13+
--cui-btn-hover-border-color: #{shade-color($cd-violet, 10%)};
14+
--cui-btn-focus-shadow-rgb: var(--cd-violet-rgb);
15+
--cui-btn-active-color: var(--cui-btn-hover-color);
16+
--cui-btn-active-bg: #{shade-color($cd-violet, 20%)};
17+
--cui-btn-active-border-color: #{shade-color($cd-violet, 20%)};
18+
}
19+
// scss-docs-end btn-css-vars-example

docs/assets/scss/_callouts.scss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
//
44

55
.docs-callout {
6+
--#{$prefix}link-color-rgb: var(--cd-callout-link);
7+
--#{$prefix}code-color: var(--cd-callout-code-color);
8+
69
padding: 1.25rem;
710
margin-top: 1.25rem;
811
margin-bottom: 1.25rem;
9-
background-color: var(--bd-callout-bg, var(--cui-gray-100));
10-
border-left: .25rem solid var(--bd-callout-border, var(--cui-gray-300));
12+
background-color: var(--cd-callout-bg, var(--cui-gray-100));
13+
border-left: .25rem solid var(--cd-callout-border, var(--cui-gray-300));
1114

1215
h4 {
1316
margin-bottom: .25rem;
@@ -27,9 +30,10 @@
2730
}
2831

2932
// Variations
30-
@each $variant in $bd-callout-variants {
33+
@each $variant in $cd-callout-variants {
3134
.docs-callout-#{$variant} {
32-
--bd-callout-bg: rgba(var(--cui-#{$variant}-rgb), .075);
33-
--bd-callout-border: rgba(var(--cui-#{$variant}-rgb), .5);
35+
--cd-callout-color: var(--cui-#{$variant}-text-emphasis);
36+
--cd-callout-bg: rgba(var(--cui-#{$variant}-rgb), .1);
37+
--cd-callout-border: var(--cui-#{$variant});
3438
}
3539
}

0 commit comments

Comments
 (0)