From aa0b1cb59cb6ce48c6d1cbc6b965fff813981116 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sat, 14 Aug 2021 00:35:06 +0300 Subject: [PATCH] #48 : Add customized h1, h2 --- src/docs/Layouts/Main.svelte | 6 +++- src/docs/Layouts/custom/H.svelte | 43 +++++++++++++++++++++++++++ src/docs/Layouts/custom/H1.svelte | 8 +++++ src/docs/Layouts/custom/H2.svelte | 8 +++++ src/docs/Layouts/custom/dom/H1.svelte | 9 ++++++ src/docs/Layouts/custom/dom/H2.svelte | 9 ++++++ src/docs/utils/string.js | 19 ++++++++++++ 7 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/docs/Layouts/custom/H.svelte create mode 100644 src/docs/Layouts/custom/H1.svelte create mode 100644 src/docs/Layouts/custom/H2.svelte create mode 100644 src/docs/Layouts/custom/dom/H1.svelte create mode 100644 src/docs/Layouts/custom/dom/H2.svelte create mode 100644 src/docs/utils/string.js diff --git a/src/docs/Layouts/Main.svelte b/src/docs/Layouts/Main.svelte index 555f3d4..926628e 100644 --- a/src/docs/Layouts/Main.svelte +++ b/src/docs/Layouts/Main.svelte @@ -3,11 +3,15 @@ import Th from './custom/Th.svelte'; import Tr from './custom/Tr.svelte'; import Td from './custom/Td.svelte'; + import H1 from './custom/H1.svelte'; + import H2 from './custom/H2.svelte'; export { Table as table, Th as th, Tr as tr, - Td as td + Td as td, + H1 as h1, + H2 as h2, }; diff --git a/src/docs/Layouts/custom/H.svelte b/src/docs/Layouts/custom/H.svelte new file mode 100644 index 0000000..46d6274 --- /dev/null +++ b/src/docs/Layouts/custom/H.svelte @@ -0,0 +1,43 @@ + + + + + {title} + {#if !title} + + {/if} + + + + diff --git a/src/docs/Layouts/custom/H1.svelte b/src/docs/Layouts/custom/H1.svelte new file mode 100644 index 0000000..329c9fb --- /dev/null +++ b/src/docs/Layouts/custom/H1.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/src/docs/Layouts/custom/H2.svelte b/src/docs/Layouts/custom/H2.svelte new file mode 100644 index 0000000..ee3940e --- /dev/null +++ b/src/docs/Layouts/custom/H2.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/src/docs/Layouts/custom/dom/H1.svelte b/src/docs/Layouts/custom/dom/H1.svelte new file mode 100644 index 0000000..b444148 --- /dev/null +++ b/src/docs/Layouts/custom/dom/H1.svelte @@ -0,0 +1,9 @@ +

+ +

+ + diff --git a/src/docs/Layouts/custom/dom/H2.svelte b/src/docs/Layouts/custom/dom/H2.svelte new file mode 100644 index 0000000..6b10d49 --- /dev/null +++ b/src/docs/Layouts/custom/dom/H2.svelte @@ -0,0 +1,9 @@ +

+ +

+ + diff --git a/src/docs/utils/string.js b/src/docs/utils/string.js new file mode 100644 index 0000000..17aab07 --- /dev/null +++ b/src/docs/utils/string.js @@ -0,0 +1,19 @@ +export const parseProps = (propsStr) => { + const props = propsStr?.split(';').filter(Boolean) || [] + return props.reduce((acc, cur) => { + const prop = cur.split(':') + return { + ...acc, + [prop[0]]: prop[1] + } + }, {}) +} + +export const parseTitleStr = (titleStr) => { + const parts = titleStr.split('!') + + return { + title: parts[0], + props: parseProps(parts[1]) + } +}