From 917b4fdbe10e816dc6ff542cf9039797e54b1e21 Mon Sep 17 00:00:00 2001 From: rohit Date: Thu, 14 Mar 2024 02:31:13 +0530 Subject: [PATCH] for the kuriyan --- src/index.ts | 120 +++++++++++- src/json.ts | 111 ----------- src/templates/index.html | 388 +++++++++++++++++---------------------- 3 files changed, 282 insertions(+), 337 deletions(-) delete mode 100644 src/json.ts diff --git a/src/index.ts b/src/index.ts index 8af5c9c..7730e3a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,111 @@ -import * as hero from "./sections/hero"; -import * as aboutus from "./sections/about" -import * as guests from "./sections/guests"; -import * as schedule from "./sections/schedule"; - -export const Hero = hero; -export const aboutUs = aboutus; -export const Guests = guests; -export const Schedule = schedule; +import valueToHTML from "./utils/toJson"; +import {data} from "./utils/jsonData"; + +document.getElementById("json").innerHTML = valueToHTML(data); + +let collapsers, $selectedLI; + +function init() { + collapsers = document.querySelectorAll('#json .collapsible .collapsible') + + for (const $collapser of collapsers) { + const $parent = $collapser.parentElement + const id = Math.random().toString(36); + $parent.id = id + $parent.dataset.status = 'expanded' + $parent.onclick = e => { + onToggle(e, id, $collapser) + } + } + + const $copyPath = document.createElement('div') + $copyPath.className = 'copy-path' + + const $toolbox = document.createElement('div') + $toolbox.className = 'toolbox' + + const $expand = document.createElement('button') + $expand.id = 'expand_all' + $expand.textContent = '+' + + const $reduce = document.createElement('button') + $reduce.id = 'reduce_all' + $reduce.textContent = '-' + + $toolbox.append($expand) + $toolbox.append($reduce) + + document.body.append($toolbox) + document.body.onclick = onMouseClick + + $expand.onclick = onExpand + $reduce.onclick = onReduce +} + +function onToggle(e, id, $collapser) { + e.preventDefault() + e.stopPropagation() + const $parent = $collapser.parentElement + if ($parent.id === id) { + switch ($parent.dataset.status) { + case 'expanded': + reduce($collapser) + break + case 'reduced': + expand($collapser) + break + default: + $parent.dataset.status = 'expanded' + reduce($collapser) + } + } +} + +function onExpand() { + for (const $collapsed of collapsers) { + expand($collapsed) + } +} + +function expand($collapsed) { + const $parent = $collapsed.parentElement + if ($parent.dataset.status !== 'reduced') return + + $parent.classList.remove('collapsed') + $parent.dataset.status = 'expanded' +} + +function onReduce() { + for (const $collapsed of collapsers) { + reduce($collapsed) + } +} + +function reduce($collapsed) { + const $parent = $collapsed.parentElement + if ($parent.dataset.status !== 'expanded') return + + const $ellipsis = $parent.querySelector('.ellipsis') + if ($ellipsis) $ellipsis.dataset.value = `${$collapsed.childElementCount}` + $parent.classList.add('collapsed') + $parent.dataset.status = 'reduced' +} + +function getParentLI($element) { + if ($element && $element.tagName === 'LI') return $element + + while ($element && $element.tagName !== 'LI') { + $element = $element.parentElement + } + + return $element +} + +function onMouseClick(e) { + if ($selectedLI) $selectedLI.firstElementChild.classList.remove('selected') + + $selectedLI = getParentLI(e.target) + if ($selectedLI) $selectedLI.firstElementChild.classList.add('selected') +} + +init(); diff --git a/src/json.ts b/src/json.ts deleted file mode 100644 index 7730e3a..0000000 --- a/src/json.ts +++ /dev/null @@ -1,111 +0,0 @@ -import valueToHTML from "./utils/toJson"; -import {data} from "./utils/jsonData"; - -document.getElementById("json").innerHTML = valueToHTML(data); - -let collapsers, $selectedLI; - -function init() { - collapsers = document.querySelectorAll('#json .collapsible .collapsible') - - for (const $collapser of collapsers) { - const $parent = $collapser.parentElement - const id = Math.random().toString(36); - $parent.id = id - $parent.dataset.status = 'expanded' - $parent.onclick = e => { - onToggle(e, id, $collapser) - } - } - - const $copyPath = document.createElement('div') - $copyPath.className = 'copy-path' - - const $toolbox = document.createElement('div') - $toolbox.className = 'toolbox' - - const $expand = document.createElement('button') - $expand.id = 'expand_all' - $expand.textContent = '+' - - const $reduce = document.createElement('button') - $reduce.id = 'reduce_all' - $reduce.textContent = '-' - - $toolbox.append($expand) - $toolbox.append($reduce) - - document.body.append($toolbox) - document.body.onclick = onMouseClick - - $expand.onclick = onExpand - $reduce.onclick = onReduce -} - -function onToggle(e, id, $collapser) { - e.preventDefault() - e.stopPropagation() - const $parent = $collapser.parentElement - if ($parent.id === id) { - switch ($parent.dataset.status) { - case 'expanded': - reduce($collapser) - break - case 'reduced': - expand($collapser) - break - default: - $parent.dataset.status = 'expanded' - reduce($collapser) - } - } -} - -function onExpand() { - for (const $collapsed of collapsers) { - expand($collapsed) - } -} - -function expand($collapsed) { - const $parent = $collapsed.parentElement - if ($parent.dataset.status !== 'reduced') return - - $parent.classList.remove('collapsed') - $parent.dataset.status = 'expanded' -} - -function onReduce() { - for (const $collapsed of collapsers) { - reduce($collapsed) - } -} - -function reduce($collapsed) { - const $parent = $collapsed.parentElement - if ($parent.dataset.status !== 'expanded') return - - const $ellipsis = $parent.querySelector('.ellipsis') - if ($ellipsis) $ellipsis.dataset.value = `${$collapsed.childElementCount}` - $parent.classList.add('collapsed') - $parent.dataset.status = 'reduced' -} - -function getParentLI($element) { - if ($element && $element.tagName === 'LI') return $element - - while ($element && $element.tagName !== 'LI') { - $element = $element.parentElement - } - - return $element -} - -function onMouseClick(e) { - if ($selectedLI) $selectedLI.firstElementChild.classList.remove('selected') - - $selectedLI = getParentLI(e.target) - if ($selectedLI) $selectedLI.firstElementChild.classList.add('selected') -} - -init(); diff --git a/src/templates/index.html b/src/templates/index.html index 30bf0dc..a7777ad 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -36,227 +36,181 @@ - - + + + WMC - -
-
- -
-

Women
Maker
Celebration

-
-
-
- -
- -
-
- -
-
- Women Makers Celebration - by TinkerHub - -
-

Join us for an inspiring day filled - with learning, networking, and celebration. - Registration is now open for March 23rd but will be subject to a shortlisting - process to ensure a deeply engaging and personalized experience for all attendees. -

-
- - - - - - Note : Shortlisted attendees will be notified via email with further details. -
-
-
- -
- -
-
- - -
-
- - - -
-

Why Join Women Makers Celebration by - Tinkerhub?

-
-

The Women Makers Celebration is not just a conference; it's a platform for creating an inclusive and - diverse tech industry in Kerala and beyond. Our mission is to: -

- -

Inspire with stories from the successful Tink-Her-Hack - initiative and other remarkable women in tech.

-

Educate through hands-on workshops and sessions led by - industry experts.

-

Connect attendees with mentors, peers, and potential - employers, fostering a vibrant community of women makers.

-
-
-
- -
- -

Day 1

-
-
-

An exclusive session for top participants of - Tink-Her-Hack, featuring personalized workshops and mentoring.

-
-
-
- -
- -

Day 2

-
-
-

Open to all with registration, offering a wide - array of sessions on technology, professional development, and more.

-
-
-
- -
-

Note: Due to limited space, registration is subject to - a shortlisting process.Shortlisted attendees will be notified via email with further details.

-
- -
-
-
- -
-
-

Event Schedule

-
- -
- -
- -
-

Our Guests

-
-
- -
- -
-
-
-

- Contact Us -

-
-
-

For any inquiries about the Women Makers Celebration, registration process, - or how you can get involved, please don't hesitate to reach out to us at - hi@tinkerhub.org

- -
- -
- - -
- - +
+
+

Built by Makers, For Makers