Skip to content

Commit

Permalink
showcase button text
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieFox committed Jul 2, 2024
1 parent d51b6d9 commit 8a5f9c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
18 changes: 13 additions & 5 deletions src/component/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { node } from '../../utility/node';

import './index.css';

export const Button = function ({
export const Button = function({
text = 'Button',
srOnly = false,
iconName = false,
Expand All @@ -21,14 +21,16 @@ export const Button = function ({

this.button = node('button|class:button,tabindex:1,type:button');

this.buttonText = node('span|class:button-text');

if (text) {
const buttonText = node('span:' + text + '|class:button-text');
this.buttonText.textContent = text;

if (srOnly) {
buttonText.classList.add('sr-only');
this.buttonText.classList.add('sr-only');
}

this.button.appendChild(buttonText);
this.button.appendChild(this.buttonText);
}

if (iconName) {
Expand Down Expand Up @@ -142,6 +144,12 @@ export const Button = function ({
this.button.classList.add('active');
};

this.text = (newText) => {

this.buttonText.textContent = newText;

}

this.wrap = () => {
return form.wrap({
children: [
Expand All @@ -150,4 +158,4 @@ export const Button = function ({
});
};

};
};
11 changes: 9 additions & 2 deletions src/component/showcase/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.showcase {
display: grid;
gap: var(--showcase-padding);
grid-template-columns: 2fr 5fr;
grid-template-columns: 1fr 2fr;
grid-template-areas:
"side content";
justify-items: center;
Expand All @@ -22,12 +22,19 @@
grid-area: side;
position: sticky;
top: var(--showcase-padding);
width: 100%;
height: fit-content;
}

.showcase-content {
grid-area: content;
max-width: 50em;
}

@media (min-width: 1400px) {
.showcase-content {
grid-area: content;
max-width: 80%;
}
}

.showcase-type h1,
Expand Down
14 changes: 12 additions & 2 deletions src/component/showcase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ showcase.disable = () => {

if (showcase.state.disable) {

showcase.control.side.disable.text('Enable');
showcase.control.side.disable.active();

showcase.control.input.radio.a.disable();
Expand Down Expand Up @@ -115,6 +116,7 @@ showcase.disable = () => {

} else {

showcase.control.side.disable.text('Disable');
showcase.control.side.disable.deactive();

showcase.control.input.radio.a.enable();
Expand Down Expand Up @@ -149,6 +151,7 @@ showcase.disable = () => {

showcase.control = {
side: {},
shade: {},
input: {},
dropdown: {},
button: {},
Expand All @@ -171,7 +174,6 @@ showcase.area.render = () => {
showcase.area.assemble = () => {

showcase.control.side = {
shade: new ShadeBar(),
style: new Control_radio({
object: state.get.current(),
buttonHideInput: true,
Expand Down Expand Up @@ -317,6 +319,9 @@ showcase.area.assemble = () => {
}),
};


showcase.control.shade = new ShadeBar();

showcase.control.input.radio = {
a: new Control_radio({
object: showcase.state.get.current(),
Expand Down Expand Up @@ -570,7 +575,6 @@ showcase.area.assemble = () => {

showcase.element.showcase.appendChild(
node('div|class:showcase-side', [
showcase.control.side.shade.shadeBar(),
form.wrap({
children: [
form.inline({
Expand All @@ -596,6 +600,12 @@ showcase.area.assemble = () => {

showcase.element.showcase.appendChild(
node('div|class:showcase-content', [
form.wrap({
children: [
showcase.control.shade.shadeBar(),
]
}),
node('hr'),
form.wrap({
children: [
form.inline({
Expand Down

0 comments on commit 8a5f9c3

Please sign in to comment.