code refactoring

This commit is contained in:
sairaj mote 2024-01-13 02:25:55 +05:30
parent 3bd8fe48b6
commit c475ce20d7
7 changed files with 479 additions and 627 deletions

View File

@ -331,114 +331,6 @@ ul {
margin-left: 0.5rem; margin-left: 0.5rem;
} }
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #50cb93;
}
.token.punctuation,
.token.tag {
color: #29b6f6;
}
.token.attr-name,
.token.namespace,
.token.deleted {
color: #1de9b6;
}
.token.function-name {
color: #6196cc;
}
.token.boolean,
.token.number,
.token.function {
color: #f08d49;
}
.token.property,
.token.class-name,
.token.constant,
.token.symbol {
color: #f8c555;
}
.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
color: #ff6767;
}
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
color: #84ffff;
}
.token.operator,
.token.entity,
.token.url {
color: #67cdcc;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.inserted {
color: green;
}
pre {
max-width: 100%;
margin: 1rem 0;
padding: 0 1.5rem;
overflow-x: auto;
font-size: 0.9rem;
font-weight: 500;
white-space: pre;
border-radius: 0.5rem;
background: rgba(0, 0, 0, 0.9);
line-height: 1.7;
}
code {
border-radius: 0.3rem;
font-weight: 400;
padding: 0.2rem 0.4rem;
background: rgba(var(--text-color), 0.1);
color: rgba(255, 255, 255, 0.9);
}
code * {
color: rgba(255, 255, 255, 0.9);
font-family: "Roboto Mono", monospace;
}
pre code {
line-height: 1.4;
border-radius: none;
background: none;
width: 100%;
}
h1, h1,
h2, h2,
h3, h3,

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,7 @@ strong {
line-height: 1.7; line-height: 1.7;
color: rgba(var(--text-color), 0.9); color: rgba(var(--text-color), 0.9);
} }
img { img {
object-fit: cover; object-fit: cover;
} }
@ -53,6 +54,7 @@ img {
a { a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
&:focus-visible { &:focus-visible {
box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset;
} }
@ -67,12 +69,15 @@ button {
a:any-link:focus-visible { a:any-link:focus-visible {
outline: rgba(var(--text-color), 1) 0.1rem solid; outline: rgba(var(--text-color), 1) 0.1rem solid;
} }
sm-button { sm-button {
--border-radius: 0.3rem; --border-radius: 0.3rem;
} }
ul { ul {
list-style: none; list-style: none;
} }
.table { .table {
display: grid; display: grid;
gap: 0.5rem; gap: 0.5rem;
@ -84,45 +89,56 @@ ul {
border-collapse: separate; border-collapse: separate;
border-spacing: 1rem 1.5rem; border-spacing: 1rem 1.5rem;
background-color: rgba(var(--text-color), 0.04); background-color: rgba(var(--text-color), 0.04);
p:only-of-type { p:only-of-type {
margin-bottom: 0; margin-bottom: 0;
} }
} }
.tr { .tr {
display: grid; display: grid;
gap: 1rem; gap: 1rem;
padding: 1rem; padding: 1rem;
grid-template-columns: 11rem 1fr; grid-template-columns: 11rem 1fr;
width: 100%; width: 100%;
&:nth-of-type(odd) { &:nth-of-type(odd) {
background-color: rgba(var(--text-color), 0.04); background-color: rgba(var(--text-color), 0.04);
} }
p { p {
min-width: 30ch; min-width: 30ch;
} }
} }
.flex { .flex {
display: flex; display: flex;
} }
.grid { .grid {
display: grid; display: grid;
} }
.hide { .hide {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
} }
.hide-completely { .hide-completely {
display: none !important; display: none !important;
} }
.no-transformations { .no-transformations {
transform: none !important; transform: none !important;
} }
.overflow-ellipsis { .overflow-ellipsis {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.breakable { .breakable {
overflow-wrap: break-word; overflow-wrap: break-word;
word-wrap: break-word; word-wrap: break-word;
@ -133,21 +149,27 @@ ul {
-webkit-hyphens: auto; -webkit-hyphens: auto;
hyphens: auto; hyphens: auto;
} }
.full-bleed { .full-bleed {
grid-column: 1/4; grid-column: 1/4;
} }
.h1 { .h1 {
font-size: 2.5rem; font-size: 2.5rem;
} }
.h2 { .h2 {
font-size: 2rem; font-size: 2rem;
} }
.h3 { .h3 {
font-size: 1.4rem; font-size: 1.4rem;
} }
.h4 { .h4 {
font-size: 1rem; font-size: 1rem;
} }
.h5 { .h5 {
font-size: 0.8rem; font-size: 0.8rem;
} }
@ -155,262 +177,198 @@ ul {
.uppercase { .uppercase {
text-transform: uppercase; text-transform: uppercase;
} }
.capitalize { .capitalize {
text-transform: capitalize; text-transform: capitalize;
} }
.flex { .flex {
display: flex; display: flex;
} }
.grid { .grid {
display: grid; display: grid;
} }
.grid-3 { .grid-3 {
grid-template-columns: 1fr auto auto; grid-template-columns: 1fr auto auto;
} }
.flow-column { .flow-column {
grid-auto-flow: column; grid-auto-flow: column;
} }
.gap-0-5 { .gap-0-5 {
gap: 0.5rem; gap: 0.5rem;
} }
.gap-1 { .gap-1 {
gap: 1rem; gap: 1rem;
} }
.gap-1-5 { .gap-1-5 {
gap: 1.5rem; gap: 1.5rem;
} }
.gap-2 { .gap-2 {
gap: 2rem; gap: 2rem;
} }
.gap-3 { .gap-3 {
gap: 3rem; gap: 3rem;
} }
.text-align-right { .text-align-right {
text-align: right; text-align: right;
} }
.align-start { .align-start {
align-items: flex-start; align-items: flex-start;
} }
.align-center { .align-center {
align-items: center; align-items: center;
} }
.text-center { .text-center {
text-align: center; text-align: center;
} }
.justify-start { .justify-start {
justify-content: start; justify-content: start;
} }
.justify-center { .justify-center {
justify-content: center; justify-content: center;
} }
.justify-right { .justify-right {
margin-left: auto; margin-left: auto;
} }
.align-self-center { .align-self-center {
align-self: center; align-self: center;
} }
.justify-self-center { .justify-self-center {
justify-self: center; justify-self: center;
} }
.justify-self-start { .justify-self-start {
justify-self: start; justify-self: start;
} }
.justify-self-end { .justify-self-end {
justify-self: end; justify-self: end;
} }
.direction-column { .direction-column {
flex-direction: column; flex-direction: column;
} }
.space-between { .space-between {
justify-content: space-between; justify-content: space-between;
} }
.w-100 { .w-100 {
width: 100%; width: 100%;
} }
.color-0-8 { .color-0-8 {
color: rgba(var(--text-color), 0.8); color: rgba(var(--text-color), 0.8);
} }
.weight-400 { .weight-400 {
font-weight: 400; font-weight: 400;
} }
.weight-500 { .weight-500 {
font-weight: 500; font-weight: 500;
} }
.ripple { .ripple {
height: 8rem; height: 8rem;
width: 8rem; width: 8rem;
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
transform: scale(0); transform: scale(0);
background: radial-gradient( background: radial-gradient(circle,
circle,
rgba(var(--text-color), 0.3) 0%, rgba(var(--text-color), 0.3) 0%,
rgba(0, 0, 0, 0) 50% rgba(0, 0, 0, 0) 50%);
);
pointer-events: none; pointer-events: none;
} }
.interact { .interact {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
.observe-empty-state:empty { .observe-empty-state:empty {
display: none; display: none;
} }
.observe-empty-state:not(:empty)~.empty-state { .observe-empty-state:not(:empty)~.empty-state {
display: none; display: none;
} }
.icon { .icon {
width: 1.5rem; width: 1.5rem;
height: 1.5rem; height: 1.5rem;
fill: rgba(var(--text-color), 0.9); fill: rgba(var(--text-color), 0.9);
} }
.button__icon { .button__icon {
height: 1.2rem; height: 1.2rem;
width: 1.2rem; width: 1.2rem;
&--left { &--left {
margin-right: 0.5rem; margin-right: 0.5rem;
} }
&--right { &--right {
margin-left: 0.5rem; margin-left: 0.5rem;
} }
} }
//Syntax highlighting
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #50cb93;
}
.token.punctuation,
.token.tag {
color: #29b6f6;
}
.token.attr-name,
.token.namespace,
.token.deleted {
color: #1de9b6;
}
.token.function-name {
color: #6196cc;
}
.token.boolean,
.token.number,
.token.function {
color: #f08d49;
}
.token.property,
.token.class-name,
.token.constant,
.token.symbol {
color: #f8c555;
}
.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
color: #ff6767;
}
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
color: #84ffff;
}
.token.operator,
.token.entity,
.token.url {
color: #67cdcc;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.inserted {
color: green;
}
pre {
max-width: 100%;
margin: 1rem 0;
padding: 0 1.5rem;
overflow-x: auto;
font-size: 0.9rem;
font-weight: 500;
white-space: pre;
border-radius: 0.5rem;
background: rgba(0, 0, 0, 0.9);
line-height: 1.7;
}
code {
border-radius: 0.3rem;
font-weight: 400;
padding: 0.2rem 0.4rem;
background: rgba(var(--text-color), 0.1);
color: rgba(255, 255, 255, 0.9);
}
code * {
color: rgba(255, 255, 255, 0.9);
font-family: "Roboto Mono", monospace;
}
pre code {
line-height: 1.4;
border-radius: none;
background: none;
width: 100%;
}
//
h1, h1,
h2, h2,
h3, h3,
h4.h5 { h4.h5 {
font-family: "Poppins", sans-serif; font-family: "Poppins", sans-serif;
} }
h2 { h2 {
margin: 3rem 0 1rem 0; margin: 3rem 0 1rem 0;
text-transform: capitalize; text-transform: capitalize;
} }
main { main {
display: grid; display: grid;
height: 100%; height: 100%;
} }
#main_header { #main_header {
padding: 0.5rem 1.5rem; padding: 0.5rem 1.5rem;
border-bottom: 1px solid rgba(var(--text-color), 0.1); border-bottom: 1px solid rgba(var(--text-color), 0.1);
} }
#side_nav_button { #side_nav_button {
padding: 0.5rem; padding: 0.5rem;
margin-left: -0.5rem; margin-left: -0.5rem;
} }
.right { .right {
max-height: 100%; max-height: 100%;
overflow-y: auto; overflow-y: auto;
} }
#side_nav { #side_nav {
&> :last-child { &> :last-child {
padding-bottom: 3rem; padding-bottom: 3rem;
} }
h4 { h4 {
font-size: 0.9rem; font-size: 0.9rem;
letter-spacing: 0.08em; letter-spacing: 0.08em;
@ -418,27 +376,33 @@ main {
padding: 1.5rem; padding: 1.5rem;
} }
} }
.right { .right {
padding: 1.5rem; padding: 1.5rem;
h1 { h1 {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
} }
.list { .list {
list-style: none; list-style: none;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 0.8rem; margin-bottom: 0.8rem;
} }
.list__item { .list__item {
display: flex; display: flex;
padding: 0.8rem 1.5rem; padding: 0.8rem 1.5rem;
text-transform: capitalize; text-transform: capitalize;
&--active { &--active {
color: var(--accent-color); color: var(--accent-color);
background: rgba(var(--text-color), 0.06); background: rgba(var(--text-color), 0.06);
} }
} }
.card { .card {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -448,31 +412,39 @@ main {
min-width: min(24rem, 80%); min-width: min(24rem, 80%);
background-color: rgba(var(--text-color), 0.06); background-color: rgba(var(--text-color), 0.06);
} }
sm-carousel { sm-carousel {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
sm-tab-header { sm-tab-header {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
.page { .page {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-bottom: 3rem; padding-bottom: 3rem;
} }
ol { ol {
padding: 0.6rem 1rem; padding: 0.6rem 1rem;
max-width: 75ch; max-width: 75ch;
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
li { li {
margin-bottom: 1rem; margin-bottom: 1rem;
&:last-of-type { &:last-of-type {
margin-bottom: 0; margin-bottom: 0;
} }
} }
} }
strong { strong {
max-width: 65ch; max-width: 65ch;
} }
strong.important { strong.important {
display: flex; display: flex;
padding: 0.5rem; padding: 0.5rem;
@ -481,6 +453,7 @@ strong.important {
color: rgba(0, 0, 0, 0.8); color: rgba(0, 0, 0, 0.8);
background-color: khaki; background-color: khaki;
} }
.highlight { .highlight {
display: inline-flex; display: inline-flex;
font-family: "Roboto Mono", monospace; font-family: "Roboto Mono", monospace;
@ -490,24 +463,29 @@ strong.important {
font-size: 0.9rem; font-size: 0.9rem;
line-height: 1.6; line-height: 1.6;
} }
#total_components_count { #total_components_count {
font-size: 4rem; font-size: 4rem;
} }
#components_selection_list { #components_selection_list {
display: grid; display: grid;
gap: 1.5rem; gap: 1.5rem;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
padding: 1.5rem 0 3rem 0; padding: 1.5rem 0 3rem 0;
} }
.comp-checkbox__title { .comp-checkbox__title {
margin-left: 0.5rem; margin-left: 0.5rem;
} }
.auto-grid-2 { .auto-grid-2 {
justify-content: center; justify-content: center;
justify-items: center; justify-items: center;
text-align: center; text-align: center;
grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
} }
.screenshot { .screenshot {
object-fit: cover; object-fit: cover;
object-position: top; object-position: top;
@ -517,50 +495,62 @@ strong.important {
justify-self: center; justify-self: center;
box-shadow: 0 0.5rem 1.5rem -0.5rem rgba(0, 0, 0, 0.3), 0 0 0 0.3rem black; box-shadow: 0 0.5rem 1.5rem -0.5rem rgba(0, 0, 0, 0.3), 0 0 0 0.3rem black;
} }
@media screen and (max-width: 640px) { @media screen and (max-width: 640px) {
main { main {
grid-template-rows: auto 1fr; grid-template-rows: auto 1fr;
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
} }
@media screen and (min-width: 640px) { @media screen and (min-width: 640px) {
sm-popup { sm-popup {
--width: 32rem; --width: 32rem;
} }
#main_header { #main_header {
padding: 1rem 1.5rem; padding: 1rem 1.5rem;
grid-area: main-header; grid-area: main-header;
} }
#side_nav_button { #side_nav_button {
display: none; display: none;
} }
main { main {
grid-template-columns: 14rem minmax(0, 1fr); grid-template-columns: 14rem minmax(0, 1fr);
grid-template-areas: "main-header main-header" ". ."; grid-template-areas: "main-header main-header" ". .";
} }
.right { .right {
display: grid; display: grid;
grid-template-columns: 1fr 90% 1fr; grid-template-columns: 1fr 90% 1fr;
&>* { &>* {
grid-column: 2/3; grid-column: 2/3;
} }
} }
.page__title { .page__title {
font-size: 2.5rem; font-size: 2.5rem;
} }
#overview_page { #overview_page {
display: grid; display: grid;
gap: 1.5rem; gap: 1.5rem;
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
&>div:first-of-type { &>div:first-of-type {
grid-column: 2/3; grid-column: 2/3;
text-align: right; text-align: right;
} }
&>div:nth-of-type(2) { &>div:nth-of-type(2) {
grid-row: 1/2; grid-row: 1/2;
} }
} }
} }
@media (any-hover: hover) { @media (any-hover: hover) {
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0.5rem; width: 0.5rem;
@ -570,10 +560,12 @@ strong.important {
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background: rgba(var(--text-color), 0.3); background: rgba(var(--text-color), 0.3);
border-radius: 1rem; border-radius: 1rem;
&:hover { &:hover {
background: rgba(var(--text-color), 0.5); background: rgba(var(--text-color), 0.5);
} }
} }
.list__item:hover { .list__item:hover {
background: rgba(var(--text-color), 0.1); background: rgba(var(--text-color), 0.1);
cursor: pointer; cursor: pointer;

View File

@ -115,24 +115,38 @@ template.innerHTML = /*html*/`
class SyntaxHighlighter extends HTMLElement { class SyntaxHighlighter extends HTMLElement {
static loaded = false; static loaded = false;
render = (language = 'javascript') => { escapeHtml = (str) => {
return str.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/\u00a0/g, ' ');
}
render = (language = 'html') => {
if (!Prism.languages.hasOwnProperty(language)) if (!Prism.languages.hasOwnProperty(language))
return console.error(`Language ${language} not supported`); return console.error(`Language ${language} not supported`);
const code = this.innerHTML; const code = this.innerHTML;
const highlightedCode = Prism.highlight(code, Prism.languages[language], language); // remove equal indentation from lines
const lines = code.split('\n');
const indent = lines.reduce((acc, line) => {
if (/^\s*$/.test(line)) return acc; // ignore empty lines
const lineIndent = line.match(/^\s*/)[0].length;
return Math.min(acc, lineIndent);
}, Infinity);
const regex = new RegExp(`^\\s{${indent}}`);
const formattedCode = lines.map(line => line.replace(regex, '')).join('\n');
this.innerHTML = ` this.innerHTML = `
<pre><code class="language-${language}">${highlightedCode}</code></pre> <pre><code class="language-${language}">${formattedCode}</code></pre>
`; `;
} }
connectedCallback() { connectedCallback() {
console.log('connected', SyntaxHighlighter.loaded);
if (!SyntaxHighlighter.loaded) { if (!SyntaxHighlighter.loaded) {
document.head.appendChild(template.content.cloneNode(true)); document.head.appendChild(template.content.cloneNode(true));
SyntaxHighlighter.loaded = true; SyntaxHighlighter.loaded = true;
} }
setTimeout(() => { if (this.querySelector('template')) {
this.render(this.getAttribute('language') || 'javascript'); this.innerHTML = this.querySelector('template').innerHTML;
}, 0); }
this.innerHTML = this.escapeHtml(this.innerHTML);
this.render(this.getAttribute('language') || 'html');
} }
disconnectedCallback() { disconnectedCallback() {

File diff suppressed because one or more lines are too long

View File

@ -16,10 +16,6 @@
<body class="hide-completely"> <body class="hide-completely">
<sm-notifications id="notification_drawer"></sm-notifications> <sm-notifications id="notification_drawer"></sm-notifications>
<audio id="notification_sound">
<source src="https://rmservices.duckdns.org/files/notification-sound.mp3" type="audio/mpeg">
<source src="https://rmservices.duckdns.org/files/notification-sound.ogg" type="audio/ogg">
</audio>
<main> <main>
<header id="main_header" class="flex align-center space-between"> <header id="main_header" class="flex align-center space-between">
<button id="side_nav_button" class="interact" onclick="getRef('side_nav').open()" <button id="side_nav_button" class="interact" onclick="getRef('side_nav').open()"
@ -108,11 +104,9 @@
</li> </li>
<li> <li>
Link the downloaded js before <span class="highlight">&lt;/body&gt;</span> Link the downloaded js before <span class="highlight">&lt;/body&gt;</span>
<pre> <syntax-highlighter>
<code> <script src=".../components.js"></script>
&lt;script src=".../components.js"&gt;&lt;/script&gt; </syntax-highlighter>
</code>
</pre>
</li> </li>
</ol> </ol>
<div class="grid grid-3 gap-0-5 align-center"> <div class="grid grid-3 gap-0-5 align-center">
@ -198,23 +192,19 @@
</div> </div>
</section> </section>
<h4>How to define variant</h4> <h4>How to define variant</h4>
<pre> <syntax-highlighter>
<code> <sm-button variant="primary">Primary</sm-button>
&lt;sm-button variant="primary"&gt;primary&lt;/sm-button&gt; <sm-button variant="outlined">Outlined</sm-button>
&lt;sm-button variant="outlined"&gt;outlined&lt;/sm-button&gt; <sm-button variant="no-outline">No outline</sm-button>
&lt;sm-button variant="no-outline"&gt;no-outline&lt;/sm-button&gt; </syntax-highlighter>
</code>
</pre>
<h2>States</h2> <h2>States</h2>
<h4>Disabled</h4> <h4>Disabled</h4>
<p>To disable the button add <span class="highlight">disabled</span> attribute.</p> <p>To disable the button add <span class="highlight">disabled</span> attribute.</p>
<sm-button disabled>Disabled</sm-button> <sm-button disabled>Disabled</sm-button>
<pre> <syntax-highlighter>
<code> <sm-button disabled>Disabled</sm-button>
&lt;sm-button disabled&gt;Disabled&lt;/sm-button&gt; </syntax-highlighter>
</code>
</pre>
<h2>Attributes</h2> <h2>Attributes</h2>
<p>All the native HTML checkbox attributes are valid</p> <p>All the native HTML checkbox attributes are valid</p>
<section class="table"> <section class="table">
@ -292,13 +282,11 @@
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident, optio.</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident, optio.</p>
</div> </div>
</sm-carousel> </sm-carousel>
<pre> <syntax-highlighter>
<code> <sm-carousel align-items="start" indicator>
&lt;sm-carousel align-items="start" indicator&gt; <!-- carousel items -->
&lt;!-- carousel items --&gt; </sm-carousel>
&lt;/sm-carousel&gt; </syntax-highlighter>
</code>
</pre>
<h2>Custom attributes</h2> <h2>Custom attributes</h2>
<p>These attributes cane used to customize carousel behaviour and features</p> <p>These attributes cane used to customize carousel behaviour and features</p>
<section class="table"> <section class="table">
@ -379,13 +367,13 @@
Checked checkbox Checked checkbox
</div> </div>
</sm-checkbox> </sm-checkbox>
<pre> <syntax-highlighter>
<code> <sm-checkbox checked>
&lt;sm-checkbox checked&gt; <div style="margin-left: 0.5rem;">
&lt;div style="margin-left: 0.5rem;"&gt;Checked checkbox&lt;/div&gt; Checked checkbox
&lt;/sm-checkbox&gt; </div>
</code> </sm-checkbox>
</pre> </syntax-highlighter>
<h4>Disabled</h4> <h4>Disabled</h4>
<p>To disable the checkbox add <span class="highlight">disabled</span> attribute.</p> <p>To disable the checkbox add <span class="highlight">disabled</span> attribute.</p>
@ -394,13 +382,13 @@
Disabled checkbox Disabled checkbox
</div> </div>
</sm-checkbox> </sm-checkbox>
<pre> <syntax-highlighter>
<code> <sm-checkbox disabled>
&lt;sm-checkbox disabled&gt; <div style="margin-left: 0.5rem;">
&lt;div style="margin-left: 0.5rem;"&gt;Disabled checkbox&lt;/div&gt; Disabled checkbox
&lt;/sm-checkbox&gt; </div>
</code> </sm-checkbox>
</pre> </syntax-highlighter>
<h2>Attributes</h2> <h2>Attributes</h2>
<p>All the native HTML checkbox attributes are valid</p> <p>All the native HTML checkbox attributes are valid</p>
@ -466,24 +454,25 @@
<section id="copy_page" class="page hide-completely"> <section id="copy_page" class="page hide-completely">
<h1 class="page__title">Copy</h1> <h1 class="page__title">Copy</h1>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<sm-copy value="copy this message"> <sm-copy value="this wiil be copied">
<div>ssafd</div> <div>this will be copied</div>
</sm-copy> </sm-copy>
<pre> <syntax-highlighter>
<code> <sm-copy value="this wiil be copied">
&lt;sm-copy value="copy this message"&gt;&lt;/sm-copy&gt; <div>this will be copied</div>
</code> </sm-copy>
</pre> </syntax-highlighter>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-copy id="text_to_copy" value="sample text"&gt;&lt;/sm-copy&gt; <sm-copy id="text_to_copy" value="sample text"></sm-copy>
&lt;script&gt; <script>
const textToCopy = document.getElementById('text_to_copy') const textToCopy = document.getElementById('text_to_copy')
textToCopy.value = 'Different value'; /* Setting value to be copied */ textToCopy.value = 'Different value'; /* Setting value to be copied */
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
<h2>Attributes</h2> <h2>Attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -542,11 +531,9 @@
</p> </p>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<file-input multiple>Select multiple files</file-input> <file-input multiple>Select multiple files</file-input>
<pre> <syntax-highlighter>
<code> <file-input multiple>Select multiple files</file-input>
&lt;file-input multiple&gt;Select multiple files&lt;/file-input&gt; </syntax-highlighter>
</code>
</pre>
<h2>Attributes</h2> <h2>Attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -651,40 +638,36 @@
</div> </div>
</section> </section>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;hamburger-menu id="navigation_drawer"&gt; <hamburger-menu id="navigation_drawer">
<!-- Navigation links --> <!-- Navigation links -->
&lt;/hamburger-menu&gt; </hamburger-menu>
&lt;script&gt; <script>
const navigationDrawer = document.getElementById('navigation_drawer') const navigationDrawer = document.getElementById('navigation_drawer')
const navigationDrawerButton = document.getElementById('navigation_drawer_button') const navigationDrawerButton = document.getElementById('navigation_drawer_button')
navigationDrawerButton.addEventListner('click', e => { navigationDrawerButton.addEventListner('click', e => {
navigationDrawer.open(); // Will open hamburger menu on mobile devices when hidden navigationDrawer.open(); // Will open hamburger menu on mobile devices when hidden
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="input_page" class="page hide-completely"> <section id="input_page" class="page hide-completely">
<h1 class="page__title">Input</h1> <h1 class="page__title">Input</h1>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<sm-input id="my_input" placeholder="Email" type="email" value="john@doe" animate> <sm-input id="my_input" placeholder="Email" type="email" value="john@doe" animate>
</sm-input> </sm-input>
<pre> <syntax-highlighter>
<code> <sm-input id="my_input" placeholder="Email" type="email" value="john@doe" animate></sm-input>
&lt;sm-input id="my_input" placeholder="Email" type="email" value="john@doe" animate&gt;&lt;/sm-input&gt; </syntax-highlighter>
</code>
</pre>
<h2>Variants</h2> <h2>Variants</h2>
<p><span class="highlight">outlined</span> is only one styled variation. Default is filled which doesn't <p><span class="highlight">outlined</span> is only one styled variation. Default is filled which doesn't
require variant specified.</p> require variant specified.</p>
<sm-input placeholder="Name" variant="outlined" animate></sm-input> <sm-input placeholder="Name" variant="outlined" animate></sm-input>
<pre> <syntax-highlighter>
<code> <sm-input placeholder="Name" variant="outlined" animate></sm-input>
&lt;sm-input placeholder="Name" variant="outlined" animate&gt;&lt;/sm-input&gt; </syntax-highlighter>
</code>
</pre>
<h2>Custom Attributes</h2> <h2>Custom Attributes</h2>
<p>All the native HTML input attributes are valid. These are additional attributes which can be used to <p>All the native HTML input attributes are valid. These are additional attributes which can be used to
add more functionality</p> add more functionality</p>
@ -799,9 +782,9 @@
</p> </p>
</div> </div>
</section> </section>
<pre> <syntax-highlighter>
<code> <template>
&lt;script&gt; <script>
/* Setting custom validation function */ /* Setting custom validation function */
document.getElelementById('my_input').customValidation = myValidation document.getElelementById('my_input').customValidation = myValidation
@ -809,9 +792,9 @@
/* Custom validation logic */ /* Custom validation logic */
return Boolean; /* Must return Boolean ( true/ false ) */ return Boolean; /* Must return Boolean ( true/ false ) */
} }
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="menu_page" class="page hide-completely"> <section id="menu_page" class="page hide-completely">
@ -822,15 +805,13 @@
<menu-option>second option</menu-option> <menu-option>second option</menu-option>
<menu-option>third option</menu-option> <menu-option>third option</menu-option>
</sm-menu> </sm-menu>
<pre> <syntax-highlighter>
<code> <sm-menu>
&lt;sm-menu&gt; <menu-option>first option</menu-option>
&lt;menu-option&gt;first option&lt;/menu-option&gt; <menu-option>second option</menu-option>
&lt;menu-option&gt;second option&lt;/menu-option&gt; <menu-option>third option</menu-option>
&lt;menu-option&gt;third option&lt;/menu-option&gt; </sm-menu>
&lt;/sm-menu&gt; </syntax-highlighter>
</code>
</pre>
<h2>Custom Attributes</h2> <h2>Custom Attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -913,15 +894,15 @@
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<sm-button onclick="getRef('notification_drawer').push('This is a notification', {pinned: true})"> <sm-button onclick="getRef('notification_drawer').push('This is a notification', {pinned: true})">
push pinned notification</sm-button> push pinned notification</sm-button>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-notifications id="notification_drawer"&gt;&lt;/sm-notifications&gt; <sm-notifications id="notification_drawer"></sm-notifications>
&lt;script&gt; <script>
const notificationDrawer = document.getElementById('notification_drawer') const notificationDrawer = document.getElementById('notification_drawer')
notificationDrawer.push('This is a notification', { pinned: true }) notificationDrawer.push('This is a notification', { pinned: true })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="popup_page" class="page hide-completely"> <section id="popup_page" class="page hide-completely">
@ -937,28 +918,30 @@
veritatis debitis repellat laudantium corporis velit adipisci!</p> veritatis debitis repellat laudantium corporis velit adipisci!</p>
</sm-popup> </sm-popup>
<sm-button onclick="getRef('my_popup').show()">show popup</sm-button> <sm-button onclick="getRef('my_popup').show()">show popup</sm-button>
<pre> <syntax-highlighter>
<code> <sm-popup id="my_popup">
&lt;sm-popup id="my_popup"&gt; <h2>Title</h2>
&lt;!--Popup content --&gt; <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolore tenetur natus, pariatur
&lt;/sm-popup&gt; beatae
</code> veritatis debitis repellat laudantium corporis velit adipisci!</p>
</pre> </sm-popup>
<sm-button onclick="getRef('my_popup').show()">show popup</sm-button>
</syntax-highlighter>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-popup id="my_popup"&gt; <sm-popup id="my_popup">
&lt;!--Popup content --&gt; <!--Popup content -->
&lt;/sm-popup&gt; </sm-popup>
&lt;sm-button id="show_popup_button"&gt;Show popup&lt;/sm-button&gt; <sm-button id="show_popup_button">Show popup</sm-button>
&lt;script&gt; <script>
const myPopup = document.getElementById('my_popup') const myPopup = document.getElementById('my_popup')
document.getElementById('show_popup_button').addEventListener('click', e =&gt; { document.getElementById('show_popup_button').addEventListener('click', e => {
myPopup.show({ options }); myPopup.show({ options });
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
<h2>Custom Attributes</h2> <h2>Custom Attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -1104,19 +1087,17 @@
<div>&nbsp;&nbsp;🤷</div> <div>&nbsp;&nbsp;🤷</div>
</sm-radio> </sm-radio>
</div> </div>
<pre> <syntax-highlighter>
<code> <sm-radio name="abc" value="on" checked>
&lt;sm-radio name="abc" value="on" checked&gt; <div>&nbsp;&nbsp;On</div>
&lt;div&gt;&nbsp;&nbsp;On&lt;/div&gt; </sm-radio>
&lt;/sm-radio&gt; <sm-radio name="abc" value="off">
&lt;sm-radio name="abc" value="off"&gt; <div>&nbsp;&nbsp;Off</div>
&lt;div&gt;&nbsp;&nbsp;Off&lt;/div&gt; </sm-radio>
&lt;/sm-radio&gt; <sm-radio name="abc" value="🤷">
&lt;sm-radio name="abc" value="🤷"&gt; <div>&nbsp;&nbsp;🤷</div>
&lt;div&gt;&nbsp;&nbsp;🤷&lt;/div&gt; </sm-radio>
&lt;/sm-radio&gt; </syntax-highlighter>
</code>
</pre>
<h2>States</h2> <h2>States</h2>
<h4>Checked</h4> <h4>Checked</h4>
<p>To make switch turned on by default add <span class="highlight">checked</span> attribute.</p> <p>To make switch turned on by default add <span class="highlight">checked</span> attribute.</p>
@ -1125,13 +1106,13 @@
Checked radio button Checked radio button
</div> </div>
</sm-radio> </sm-radio>
<pre> <syntax-highlighter>
<code> <sm-radio checked>
&lt;sm-radio checked&gt; <div style="margin-left: 0.5rem;">
&lt;div&gt;On switch&lt;/div&gt; Checked radio button
&lt;/sm-radio&gt; </div>
</code> </sm-radio>
</pre> </syntax-highlighter>
<h4>Disabled</h4> <h4>Disabled</h4>
<p>To disable the radio button add <span class="highlight">disabled</span> attribute.</p> <p>To disable the radio button add <span class="highlight">disabled</span> attribute.</p>
@ -1140,14 +1121,13 @@
Disabled radio button Disabled radio button
</div> </div>
</sm-radio> </sm-radio>
<pre> <syntax-highlighter>
<code> <sm-radio disabled>
&lt;sm-radio disabled&gt; <div style="margin-left: 0.5rem;">
&lt;div&gt;Disabled switch&lt;/div&gt; Disabled radio button
&lt;/sm-radio&gt; </div>
</code> </sm-radio>
</pre> </syntax-highlighter>
<h2>Attributes</h2> <h2>Attributes</h2>
<p>All the native HTML radio attributes are valid</p> <p>All the native HTML radio attributes are valid</p>
<section class="table"> <section class="table">
@ -1196,31 +1176,24 @@
<sm-option value="2">option2</sm-option> <sm-option value="2">option2</sm-option>
<sm-option value="3">option3</sm-option> <sm-option value="3">option3</sm-option>
</sm-select> </sm-select>
<pre> <syntax-highlighter>
<code> <sm-select id="my_select">
&lt;sm-select&gt; <sm-option value="1">option1</sm-option>
&lt;sm-option value="1"&gt;option1&lt;/sm-option&gt; <sm-option value="2">option2</sm-option>
&lt;sm-option value="2"&gt;option2&lt;/sm-option&gt; <sm-option value="3">option3</sm-option>
&lt;sm-option value="3"&gt;option3&lt;/sm-option&gt; </sm-select>
&lt;/sm-select&gt; </syntax-highlighter>
</code>
</pre>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-select id="my_select"&gt; <script>
&lt;sm-option value="1"&gt;option1&lt;/sm-option&gt;
&lt;sm-option value="2"&gt;option2&lt;/sm-option&gt;
&lt;sm-option value="3"&gt;option3&lt;/sm-option&gt;
&lt;/sm-select&gt;
&lt;script&gt;
const mySelect = document.getElementById('my_select') const mySelect = document.getElementById('my_select')
mySelect.addEventListener('change', event =&gt; { mySelect.addEventListener('change', event => {
console.log(event.target.value) // logs out value of selected option console.log(event.target.value) // logs out value of selected option
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
<h2>States</h2> <h2>States</h2>
<h4>Disabled</h4> <h4>Disabled</h4>
<p>To disable the select add <span class="highlight">disabled</span> attribute.</p> <p>To disable the select add <span class="highlight">disabled</span> attribute.</p>
@ -1229,13 +1202,11 @@
<sm-option value="2">option2</sm-option> <sm-option value="2">option2</sm-option>
<sm-option value="3">option3</sm-option> <sm-option value="3">option3</sm-option>
</sm-select> </sm-select>
<pre> <syntax-highlighter>
<code> <sm-select disabled>
&lt;sm-select disabled&gt; <!-- Options -->
&lt;!-- Options --&gt; </sm-select>
&lt;/sm-select&gt; </syntax-highlighter>
</code>
</pre>
<h2>Supported events</h2> <h2>Supported events</h2>
<p>These are the events that will be fired when component state changes</p> <p>These are the events that will be fired when component state changes</p>
<section class="table"> <section class="table">
@ -1260,11 +1231,9 @@
Just drop the <span class="highlight">sm-spinner</span> in markup where you want to show the spinner Just drop the <span class="highlight">sm-spinner</span> in markup where you want to show the spinner
</p> </p>
<sm-spinner></sm-spinner> <sm-spinner></sm-spinner>
<pre> <syntax-highlighter>
<code> <sm-spinner></sm-spinner>
&lt;sm-spinner&gt;&lt;/sm-spinner&gt; </syntax-highlighter>
</code>
</pre>
</section> </section>
<section id="switch_page" class="page hide-completely"> <section id="switch_page" class="page hide-completely">
@ -1289,15 +1258,13 @@
On switch On switch
</div> </div>
</sm-switch> </sm-switch>
<pre> <syntax-highlighter>
<code> <sm-switch checked>
&lt;sm-switch checked&gt; <div slot="left">
&lt;div slot="left"&gt;
On switch On switch
&lt;/div&gt; </div>
&lt;/sm-switch&gt; </sm-switch>
</code> </syntax-highlighter>
</pre>
<h4>Disabled</h4> <h4>Disabled</h4>
<p>To disable the switch add <span class="highlight">disabled</span> attribute.</p> <p>To disable the switch add <span class="highlight">disabled</span> attribute.</p>
<sm-switch disabled> <sm-switch disabled>
@ -1305,15 +1272,13 @@
Disabled checkbox Disabled checkbox
</div> </div>
</sm-switch> </sm-switch>
<pre> <syntax-highlighter>
<code> <sm-switch disabled>
&lt;sm-switch disabled&gt; <div slot="left">
&lt;div slot="left"&gt; Disabled checkbox
Disabled switch </div>
&lt;/div&gt; </sm-switch>
&lt;/sm-switch&gt; </syntax-highlighter>
</code>
</pre>
<h2>Attributes</h2> <h2>Attributes</h2>
<p>All the native HTML checkbox attributes are valid</p> <p>All the native HTML checkbox attributes are valid</p>
@ -1357,16 +1322,14 @@
<sm-chip value="price">Price</sm-chip> <sm-chip value="price">Price</sm-chip>
<sm-chip value="rating">Rating</sm-chip> <sm-chip value="rating">Rating</sm-chip>
</sm-chips> </sm-chips>
<pre> <syntax-highlighter>
<code> <sm-chips id="sort_by">
&lt;sm-chips id="sort_by"&gt; <sm-chip value="relevance" selected>Relevance</sm-chip>
&lt;sm-chip value="relevance" selected&gt;Relevance&lt;/sm-chip&gt; <sm-chip value="popularity">Popularity</sm-chip>
&lt;sm-chip value="popularity"&gt;Popularity&lt;/sm-chip&gt; <sm-chip value="price">Price</sm-chip>
&lt;sm-chip value="price"&gt;Price&lt;/sm-chip&gt; <sm-chip value="rating">Rating</sm-chip>
&lt;sm-chip value="rating"&gt;Rating&lt;/sm-chip&gt; </sm-chips>
&lt;/sm-chips&gt; </syntax-highlighter>
</code>
</pre>
<h2>Custom attributes</h2> <h2>Custom attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -1412,22 +1375,22 @@
</div> </div>
</section> </section>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-chips id="sort_by"&gt; <sm-chips id="sort_by">
&lt;sm-chip value="relevance" selected&gt;Relevance&lt;/sm-chip&gt; <sm-chip value="relevance" selected>Relevance</sm-chip>
&lt;sm-chip value="popularity"&gt;Popularity&lt;/sm-chip&gt; <sm-chip value="popularity">Popularity</sm-chip>
&lt;sm-chip value="price"&gt;Price&lt;/sm-chip&gt; <sm-chip value="price">Price</sm-chip>
&lt;sm-chip value="rating"&gt;Rating&lt;/sm-chip&gt; <sm-chip value="rating">Rating</sm-chip>
&lt;/sm-chips&gt; </sm-chips>
&lt;script&gt; <script>
const sortBy = document.getElementById('sort_by') const sortBy = document.getElementById('sort_by')
sortBy.addEventListener('change', event =&gt; { sortBy.addEventListener('change', event => {
console.log(event.target.value) // logs out value of selected option console.log(event.target.value) // logs out value of selected option
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="tabs_page" class="page hide-completely"> <section id="tabs_page" class="page hide-completely">
@ -1453,26 +1416,26 @@
</section> </section>
</sm-tab-panels> </sm-tab-panels>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <sm-tab-header target="tab1">
&lt;sm-tab-header target="tab1"&gt; <sm-tab>Audio</sm-tab>
&lt;sm-tab&gt; <sm-tab>Video</sm-tab>
tab name </sm-tab-header>
&lt;/sm-tab&gt; <sm-tab-panels id="tab1">
&lt;sm-tab&gt; <section>
tab name <h3>Audio</h3>
&lt;/sm-tab&gt; <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem esse quod quae
&lt;/sm-tab-header&gt; repellat qui.
&lt;sm-tab-panels id="tab1"&gt; Expedita fugiat voluptates beatae itaque corporis!</p>
&lt;section&gt; </section>
&lt;!-- Panel content --&gt; <section>
&lt;/section&gt; <h3>Video</h3>
&lt;section&gt; <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Exercitationem esse quod quae
&lt;!-- Panel content --&gt; repellat qui.
&lt;/section&gt; Expedita fugiat voluptates beatae itaque corporis!</p>
&lt;/sm-tab-panels&gt; </section>
</code> </sm-tab-panels>
</pre> </syntax-highlighter>
<p> <p>
There are three components that together make the tabs components. There are three components that together make the tabs components.
<ol> <ol>
@ -1484,14 +1447,12 @@
<h3>sm-tab-header</h3> <h3>sm-tab-header</h3>
<p>This is the first half of tabs that include the tabs header and actual tab buttons.</p> <p>This is the first half of tabs that include the tabs header and actual tab buttons.</p>
<pre> <syntax-highlighter>
<code> <sm-tab-header target="tab1">
&lt;sm-tab-header variant="tab" target="tab2"&gt; <sm-tab>Audio</sm-tab>
&lt;sm-tab&gt;Audio&lt;/sm-tab&gt; <sm-tab>Video</sm-tab>
&lt;sm-tab&gt;Video&lt;/sm-tab&gt; </sm-tab-header>
&lt;/sm-tab-header&gt; </syntax-highlighter>
</code>
</pre>
<h2>Supported attributes</h2> <h2>Supported attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -1530,16 +1491,13 @@
repellat qui. Expedita fugiat voluptates beatae itaque corporis!</p> repellat qui. Expedita fugiat voluptates beatae itaque corporis!</p>
</section> </section>
</sm-tab-panels> </sm-tab-panels>
<pre> <syntax-highlighter>
<code> <sm-tab-header variant="tab" target="tab2">
&lt;sm-tab-header variant="tab" target="tab2"&gt; <sm-tab>Audio</sm-tab>
&lt;sm-tab&gt;Audio&lt;/sm-tab&gt; <sm-tab>Video</sm-tab>
&lt;sm-tab&gt;Video&lt;/sm-tab&gt; </sm-tab-header>
&lt;/sm-tab-header&gt; </syntax-highlighter>
</code>
</pre>
</section> </section>
<section id="tags_input_page" class="page hide-completely"> <section id="tags_input_page" class="page hide-completely">
<h1 class="page__title">Tags input</h1> <h1 class="page__title">Tags input</h1>
<p> <p>
@ -1548,11 +1506,10 @@
</p> </p>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<tags-input placeholder="Add tags..."></tags-input> <tags-input placeholder="Add tags..."></tags-input>
<pre> <syntax-highlighter>
<code> <tags-input placeholder="Add tags..."></tags-input>
&lt;tags-input placeholder="Add tags..."&gt;&lt;/tags-input&gt; </syntax-highlighter>
</code>
</pre>
<h2>Attributes</h2> <h2>Attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -1582,7 +1539,8 @@
<div class="tr"> <div class="tr">
<div><span class="highlight">--background</span></div> <div><span class="highlight">--background</span></div>
<p> <p>
Defines background of tags-input. Any valid CSS background property values are supported. Defines background of tags-input. Any valid CSS background property values are
supported.
</p> </p>
</div> </div>
<div class="tr"> <div class="tr">
@ -1613,39 +1571,35 @@
</div> </div>
</section> </section>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;tags-input id="get_tags" placeholder="Add tags..."&gt;&lt;/tags-input&gt; <tags-input id="get_tags" placeholder="Add tags..."></tags-input>
&lt;script&gt; <script>
const getTags = document.getElementById('get_tags') const getTags = document.getElementById('get_tags')
console.log(getTags.value); /* returns an array of string that are user input */ console.log(getTags.value); /* returns an array of string that are user input */
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="textarea_page" class="page hide-completely"> <section id="textarea_page" class="page hide-completely">
<h1 class="page__title">Textarea</h1> <h1 class="page__title">Textarea</h1>
<p>Textarea is suitable component where multiline input is required. you can either specify <p>Textarea is suitable component where multiline input is required. you can either specify
the number of lines textarea should expand or let the textarea expand according to user input until the number of lines textarea should expand or let the textarea expand according to user input
until
a max-height is reached.</p> a max-height is reached.</p>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<sm-textarea id="my_textarea" placeholder="Add some text here..." rows="4"></sm-textarea> <sm-textarea id="my_textarea" placeholder="Add some text here..." rows="4"></sm-textarea>
<pre> <syntax-highlighter>
<code> <sm-textarea id="my_textarea" placeholder="Add some text here..." rows="4"></sm-textarea>
&lt;sm-textarea id="my_textarea" placeholder="Add some text here..." rows="4"&gt;&lt;/sm-textarea&gt; </syntax-highlighter>
</code>
</pre>
<h2>Variants</h2> <h2>Variants</h2>
<p><span class="highlight">outlined</span> is only one styled variation. Default is filled which doesn't <p><span class="highlight">outlined</span> is only one styled variation. Default is filled which
doesn't
require variant specified.</p> require variant specified.</p>
<sm-textarea placeholder="This is a textarea" variant="outlined"></sm-textarea> <sm-textarea placeholder="This is a textarea" variant="outlined"></sm-textarea>
<pre> <syntax-highlighter>
<code> <sm-textarea placeholder="This is a textarea" variant="outlined"></sm-textarea>
&lt;sm-textarea placeholder="This is a textarea" variant="outlined"&gt;&lt;/sm-textarea&gt; </syntax-highlighter>
</code>
</pre>
<h2>Supported Attributes</h2> <h2>Supported Attributes</h2>
<p>All the native HTML textarea attributes are valid.</p> <p>All the native HTML textarea attributes are valid.</p>
<section class="table"> <section class="table">
@ -1741,42 +1695,44 @@
</div> </div>
</section> </section>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;sm-textarea placeholder="This is a textarea" id="my_textarea"&gt;&lt;/sm-textarea&gt; <sm-textarea placeholder="This is a textarea" id="my_textarea"></sm-textarea>
&lt;script&gt; <script>
const myTextarea = document.getElelementById('my_textarea') const myTextarea = document.getElelementById('my_textarea')
myTextarea.value = 'some string'; /* setting value of textarea */ myTextarea.value = 'some string'; /* setting value of textarea */
myTextarea.addEventListener('input', event => { myTextarea.addEventListener('input', event => {
const value = event.target.value; /* accessing value of textarea */ const value = event.target.value; /* accessing value of textarea */
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
<section id="text_field_page" class="page hide-completely"> <section id="text_field_page" class="page hide-completely">
<h1 class="page__title">Text field</h1> <h1 class="page__title">Text field</h1>
<p> <p>
This component can be used in scenarios where you need to display a name or something that user This component can be used in scenarios where you need to display a name or something that
user
should be able to edit directly should be able to edit directly
in-place instead of going to other UI element. in-place instead of going to other UI element.
</p> </p>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<text-field value="John doe"></text-field> <text-field value="John doe"></text-field>
<h2>Usage</h2> <h2>Usage</h2>
<pre> <syntax-highlighter>
<code> <template>
&lt;text-field id="name_field" value="John doe"&gt;&lt;/text-field&gt; <text-field id="name_field" value="John doe"></text-field>
&lt;script&gt; <script>
const nameField = document.getElementById('name_field') const nameField = document.getElementById('name_field')
nameField.addEventListener('change', event =&gt; { nameField.addEventListener('change', event => {
console.log(event.target.value) // logs out new value set by user console.log(event.target.value) // logs out new value set by user
console.log(nameField.value) // Accessing value directly with getter console.log(nameField.value) // Accessing value directly with getter
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
<h2>Custom attributes</h2> <h2>Custom attributes</h2>
<section class="table"> <section class="table">
<div class="tr"> <div class="tr">
@ -1821,22 +1777,21 @@
to either <span class="highlight">light</span> or <span class="highlight">dark</span> to either <span class="highlight">light</span> or <span class="highlight">dark</span>
</p> </p>
<p> <p>
By default theme is set to OS level preferred-color-scheme ( supported by Android, iOS, Windows and By default theme is set to OS level preferred-color-scheme ( supported by Android, iOS,
Windows
and
MacOS ). MacOS ).
</p> </p>
<h2>Interactive demo</h2> <h2>Interactive demo</h2>
<theme-toggle></theme-toggle> <theme-toggle></theme-toggle>
<h2>HTML</h2> <h2>HTML</h2>
<pre> <syntax-highlighter>
<code> <theme-toggle></theme-toggle>
&lt;theme-toggle&gt;&lt;/theme-toggle&gt; </syntax-highlighter>
</code>
</pre>
<h2>CSS</h2> <h2>CSS</h2>
<pre> <syntax-highlighter>
<code> <style>
&lt;style&gt;
body, body,
body * { body * {
/* Set CSS variables according to light theme or default theme*/ /* Set CSS variables according to light theme or default theme*/
@ -1845,6 +1800,7 @@
--background-color: 255, 255, 255; --background-color: 255, 255, 255;
--danger-color: red; --danger-color: red;
} }
body[data-theme='dark'], body[data-theme='dark'],
body[data-theme='dark'] * { body[data-theme='dark'] * {
/* Set CSS variables according to dark theme */ /* Set CSS variables according to dark theme */
@ -1854,14 +1810,13 @@
--background-color: 10, 10, 10; --background-color: 10, 10, 10;
--danger-color: rgb(255, 106, 106); --danger-color: rgb(255, 106, 106);
} }
body { body {
color: rgba(var(--text-color), 1); color: rgba(var(--text-color), 1);
background: rgba(var(--background-color), 1); background: rgba(var(--background-color), 1);
} }
&lt;/style&gt; </style>
</code> </syntax-highlighter>
</pre>
<h2>Styling</h2> <h2>Styling</h2>
<p>CSS variables used to style this component</p> <p>CSS variables used to style this component</p>
@ -1893,24 +1848,27 @@
<div class="tr"> <div class="tr">
<div><span class="highlight">themechange</span></div> <div><span class="highlight">themechange</span></div>
<p> <p>
Whenever theme is toggled by user the <span class="highlight">themechange</span> event is Whenever theme is toggled by user the <span class="highlight">themechange</span>
event
is
fired. <br> fired. <br>
You can listen to this event and access the current value of toggle with event object <span You can listen to this event and access the current value of toggle with event
class="highlight">event.detail.theme</span> object
<span class="highlight">event.detail.theme</span>
</p> </p>
</div> </div>
</section> </section>
<pre> <syntax-highlighter>
<code> <template>
&lt;theme-toggle id="my_theme_toggle"&gt;&lt;/theme-toggle&gt; <theme-toggle id="my_theme_toggle"></theme-toggle>
&lt;script&gt; <script>
const myThemeToggle = document.getElementById('my_theme_toggle') const myThemeToggle = document.getElementById('my_theme_toggle')
myThemeToggle.addEventListener('themechange', event =&gt; { myThemeToggle.addEventListener('themechange', event => {
console.log(event.detail.theme) // logs out current theme ( light / dark ) console.log(event.detail.theme) // logs out current theme ( light / dark )
}) })
&lt;/script&gt; </script>
</code> </template>
</pre> </syntax-highlighter>
</section> </section>
</article> </article>
</main> </main>
@ -1924,7 +1882,6 @@
<span class="comp-checkbox__title"></span> <span class="comp-checkbox__title"></span>
</sm-checkbox> </sm-checkbox>
</template> </template>
<script src="assets/prism.js" defer></script>
<script src="dist/button.min.js" defer></script> <script src="dist/button.min.js" defer></script>
<script src="dist/carousel.min.js" defer></script> <script src="dist/carousel.min.js" defer></script>
<script src="dist/checkbox.min.js" defer></script> <script src="dist/checkbox.min.js" defer></script>
@ -1946,6 +1903,7 @@
<script src="dist/text-field.min.js" defer></script> <script src="dist/text-field.min.js" defer></script>
<script src="dist/textarea.min.js" defer></script> <script src="dist/textarea.min.js" defer></script>
<script src="dist/theme-toggle.min.js" defer></script> <script src="dist/theme-toggle.min.js" defer></script>
<script src="dist/syntax-highlighter.js"></script>
<script id="default_ui_library"> <script id="default_ui_library">
const domRefs = {}; const domRefs = {};
@ -2014,14 +1972,13 @@
if (!navigator.onLine) if (!navigator.onLine)
notify( notify(
"There seems to be a problem connecting to the internet, Please check you internet connection.", "There seems to be a problem connecting to the internet, Please check you internet connection.",
"error", "error"
{ sound: true }
); );
window.addEventListener("offline", () => { window.addEventListener("offline", () => {
notify( notify(
"There seems to be a problem connecting to the internet, Please check you internet connection.", "There seems to be a problem connecting to the internet, Please check you internet connection.",
"error", "error",
{ pinned: true, sound: true } { pinned: true }
); );
}); });
window.addEventListener("online", () => { window.addEventListener("online", () => {
@ -2093,7 +2050,7 @@
//Function for displaying toast notifications. pass in error for mode param if you want to show an error. //Function for displaying toast notifications. pass in error for mode param if you want to show an error.
function notify(message, mode, options = {}) { function notify(message, mode, options = {}) {
const { pinned = false, sound } = options const { pinned = false } = options
if (mode === "error") console.error(message); if (mode === "error") console.error(message);
let icon let icon
switch (mode) { switch (mode) {
@ -2105,10 +2062,6 @@
break; break;
} }
getRef("notification_drawer").push(message, { pinned, icon }); getRef("notification_drawer").push(message, { pinned, icon });
if (navigator.onLine && sound) {
getRef("notification_sound").currentTime = 0;
getRef("notification_sound").play();
}
} }
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();

File diff suppressed because one or more lines are too long