From 49a2c4915ba60c8d24d215f288f20cfb1a32950a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABlle=20Huisman?= Date: Sun, 24 Nov 2024 13:03:20 +0100 Subject: [PATCH] Add book --- .github/FUNDING.yml | 2 + .github/labels.yml | 25 ++++++++++++ .github/renovate.json | 3 ++ .github/workflows/labels.yml | 17 ++++++++ book/book.toml | 22 ++++++++++ book/src/SUMMARY.md | 8 ++++ book/src/frameworks/README.md | 5 +++ book/src/frameworks/dioxus.md | 3 ++ book/src/frameworks/leptos.md | 3 ++ book/src/frameworks/yew.md | 3 ++ book/src/introduction.md | 27 +++++++++++++ book/theme/tabs.css | 25 ++++++++++++ book/theme/tabs.js | 75 +++++++++++++++++++++++++++++++++++ book/theme/theme.css | 3 ++ book/theme/theme.js | 13 ++++++ book/theme/trunk.css | 41 +++++++++++++++++++ book/theme/trunk.js | 53 +++++++++++++++++++++++++ 17 files changed, 328 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/labels.yml create mode 100644 .github/renovate.json create mode 100644 .github/workflows/labels.yml create mode 100644 book/book.toml create mode 100644 book/src/SUMMARY.md create mode 100644 book/src/frameworks/README.md create mode 100644 book/src/frameworks/dioxus.md create mode 100644 book/src/frameworks/leptos.md create mode 100644 book/src/frameworks/yew.md create mode 100644 book/src/introduction.md create mode 100644 book/theme/tabs.css create mode 100644 book/theme/tabs.js create mode 100644 book/theme/theme.css create mode 100644 book/theme/theme.js create mode 100644 book/theme/trunk.css create mode 100644 book/theme/trunk.js diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..df19a20 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: RustForWeb +open_collective: rustforweb diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..58d1b43 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,25 @@ +- name: 'type: bug' + description: 'Bug' + color: '3e63dd' +- name: 'type: documentation' + description: 'Documentation' + color: '3e63dd' +- name: 'type: feature' + description: 'Feature' + color: '3e63dd' +- name: 'type: maintenance' + description: 'Maintenance' + color: '3e63dd' +- name: 'type: question' + description: 'Question' + color: '3e63dd' + +- name: 'framework: dioxus' + description: 'Dioxus' + color: 'd6409f' +- name: 'framework: leptos' + description: 'Leptos' + color: 'd6409f' +- name: 'framework: yew' + color: 'd6409f' + description: 'Yew' diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..8e2b279 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,3 @@ +{ + "extends": ["config:recommended", "schedule:weekly", ":prConcurrentLimitNone", ":prHourlyLimitNone"] +} diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 0000000..3b97717 --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,17 @@ +name: Labels + +on: + workflow_dispatch: + +jobs: + sync-labels: + name: Sync Labels + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: .github/labels.yml + + - uses: EndBug/label-sync@v2 + with: + config-file: .github/labels.yml diff --git a/book/book.toml b/book/book.toml new file mode 100644 index 0000000..cb8b080 --- /dev/null +++ b/book/book.toml @@ -0,0 +1,22 @@ +[book] +authors = ["Daniƫlle Huisman"] +language = "en" +multilingual = false +src = "src" +title = "Rust Lucide" + +[preprocessor.tabs] + +[preprocessor.trunk] + +[output.html] +additional-css = ["theme/tabs.css", "theme/theme.css", "theme/trunk.css"] +additional-js = ["theme/tabs.js", "theme/theme.js", "theme/trunk.js"] +edit-url-template = "https://github.com/RustForWeb/lucide/edit/main/book/{path}" +git-repository-url = "https://github.com/RustForWeb/lucide" + +[output.trunk] +serve = true + +[rust] +edition = "2021" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md new file mode 100644 index 0000000..a5c40b7 --- /dev/null +++ b/book/src/SUMMARY.md @@ -0,0 +1,8 @@ +# Summary + +- [Introduction](./introduction.md) +- [Frameworks](./frameworks/README.md) + - [Dioxus](./frameworks/dioxus.md) + - [Leptos](./frameworks/leptos.md) + - [Yew](./frameworks/yew.md) +- [Contributing]() diff --git a/book/src/frameworks/README.md b/book/src/frameworks/README.md new file mode 100644 index 0000000..9d72b4b --- /dev/null +++ b/book/src/frameworks/README.md @@ -0,0 +1,5 @@ +# Frameworks + +- [Dioxus](./dioxus.md) +- [Leptos](./leptos.md) +- [Yew](./yew.md) diff --git a/book/src/frameworks/dioxus.md b/book/src/frameworks/dioxus.md new file mode 100644 index 0000000..c83383d --- /dev/null +++ b/book/src/frameworks/dioxus.md @@ -0,0 +1,3 @@ +# Lucide Dioxus + +TODO diff --git a/book/src/frameworks/leptos.md b/book/src/frameworks/leptos.md new file mode 100644 index 0000000..3f45909 --- /dev/null +++ b/book/src/frameworks/leptos.md @@ -0,0 +1,3 @@ +# Lucide Leptos + +TODO diff --git a/book/src/frameworks/yew.md b/book/src/frameworks/yew.md new file mode 100644 index 0000000..2fe7d1f --- /dev/null +++ b/book/src/frameworks/yew.md @@ -0,0 +1,3 @@ +# Lucide Yew + +TODO diff --git a/book/src/introduction.md b/book/src/introduction.md new file mode 100644 index 0000000..b5b4659 --- /dev/null +++ b/book/src/introduction.md @@ -0,0 +1,27 @@ + + +# Introduction + +Rust Lucide is a Rust port of [Lucide](https://lucide.dev/). + +[Lucide](https://lucide.dev/) is a beautiful & consistent icon toolkit made by the community. + +## Frameworks + +Rust Lucide is available for the following frameworks: + +- [Dioxus](https://dioxuslabs.com/) +- [Leptos](https://leptos.dev/) +- [Yew](https://yew.rs/) + +## License + +This project is available under the [MIT license](https://github.com/RustForWeb/lucide/blob/main/LICENSE.md). + +## Rust For Web + +The Rust Lucide project is part of the [Rust For Web](https://github.com/RustForWeb). + +[Rust For Web](https://github.com/RustForWeb) creates and ports web UI libraries for Rust. All projects are free and open source. diff --git a/book/theme/tabs.css b/book/theme/tabs.css new file mode 100644 index 0000000..8712b85 --- /dev/null +++ b/book/theme/tabs.css @@ -0,0 +1,25 @@ +.mdbook-tabs { + display: flex; +} + +.mdbook-tab { + background-color: var(--table-alternate-bg); + padding: 0.5rem 1rem; + cursor: pointer; + border: none; + font-size: 1.6rem; + line-height: 1.45em; +} + +.mdbook-tab.active { + background-color: var(--table-header-bg); + font-weight: bold; +} + +.mdbook-tab-content { + padding: 1rem 0rem; +} + +.mdbook-tab-content table { + margin: unset; +} diff --git a/book/theme/tabs.js b/book/theme/tabs.js new file mode 100644 index 0000000..8ba5e87 --- /dev/null +++ b/book/theme/tabs.js @@ -0,0 +1,75 @@ +/** + * Change active tab of tabs. + * + * @param {Element} container + * @param {string} name + */ +const changeTab = (container, name) => { + for (const child of container.children) { + if (!(child instanceof HTMLElement)) { + continue; + } + + if (child.classList.contains('mdbook-tabs')) { + for (const tab of child.children) { + if (!(tab instanceof HTMLElement)) { + continue; + } + + if (tab.dataset.tabname === name) { + tab.classList.add('active'); + } else { + tab.classList.remove('active'); + } + } + } else if (child.classList.contains('mdbook-tab-content')) { + if (child.dataset.tabname === name) { + child.classList.remove('hidden'); + } else { + child.classList.add('hidden'); + } + } + } +}; + +document.addEventListener('DOMContentLoaded', () => { + const tabs = document.querySelectorAll('.mdbook-tab'); + for (const tab of tabs) { + tab.addEventListener('click', () => { + if (!(tab instanceof HTMLElement)) { + return; + } + + if (!tab.parentElement || !tab.parentElement.parentElement) { + return; + } + + const container = tab.parentElement.parentElement; + const name = tab.dataset.tabname; + const global = container.dataset.tabglobal; + + changeTab(container, name); + + if (global) { + localStorage.setItem(`mdbook-tabs-${global}`, name); + + const globalContainers = document.querySelectorAll( + `.mdbook-tabs-container[data-tabglobal="${global}"]` + ); + for (const globalContainer of globalContainers) { + changeTab(globalContainer, name); + } + } + }); + } + + const containers = document.querySelectorAll('.mdbook-tabs-container[data-tabglobal]'); + for (const container of containers) { + const global = container.dataset.tabglobal; + + const name = localStorage.getItem(`mdbook-tabs-${global}`); + if (name && document.querySelector(`.mdbook-tab[data-tabname=${name}]`)) { + changeTab(container, name); + } + } +}); diff --git a/book/theme/theme.css b/book/theme/theme.css new file mode 100644 index 0000000..ea07a3e --- /dev/null +++ b/book/theme/theme.css @@ -0,0 +1,3 @@ +table { + margin: unset; +} diff --git a/book/theme/theme.js b/book/theme/theme.js new file mode 100644 index 0000000..2a07855 --- /dev/null +++ b/book/theme/theme.js @@ -0,0 +1,13 @@ +window.addEventListener('message', (event) => { + if (!event.data.mdbookTrunk) { + return; + } + + const data = event.data.mdbookTrunk; + const iframe = Array.from(document.getElementsByTagName('iframe')).find( + (iframe) => iframe.contentWindow === event.source + ); + if (iframe) { + iframe.style.height = `${data.height}px`; + } +}); diff --git a/book/theme/trunk.css b/book/theme/trunk.css new file mode 100644 index 0000000..41dc038 --- /dev/null +++ b/book/theme/trunk.css @@ -0,0 +1,41 @@ +.mdbook-trunk-iframe { + display: block; + width: 100%; + border: 0.1em solid var(--quote-border); +} + +.mdbook-trunk-files-container { + width: 100%; + border: 0.1em solid var(--quote-border); + border-top: 0em; + background-color: var(--quote-border); +} + +.mdbook-trunk-files { + display: flex; +} + +.mdbook-trunk-files-header { + padding: 0.5rem 1rem; + font-weight: bold; + font-size: 1.6rem; + line-height: 1.45em; +} + +.mdbook-trunk-file { + background-color: var(--table-alternate-bg); + padding: 0.5rem 1rem; + cursor: pointer; + border: none; + font-size: 1.6rem; + line-height: 1.45em; +} + +.mdbook-trunk-file.active { + background-color: var(--table-header-bg); + font-weight: bold; +} + +.mdbook-trunk-file-content > pre { + margin: 0rem; +} diff --git a/book/theme/trunk.js b/book/theme/trunk.js new file mode 100644 index 0000000..248ed2b --- /dev/null +++ b/book/theme/trunk.js @@ -0,0 +1,53 @@ +/** + * Change active file of files. + * + * @param {Element} container + * @param {string | null} name + */ +const changeTrunkFile = (container, name) => { + for (const child of container.children) { + if (!(child instanceof HTMLElement)) { + continue; + } + + if (child.classList.contains('mdbook-trunk-files')) { + for (const file of child.children) { + if (!(file instanceof HTMLElement)) { + continue; + } + + if (file.dataset.file === name) { + file.classList.add('active'); + } else { + file.classList.remove('active'); + } + } + } else if (child.classList.contains('mdbook-trunk-file-content')) { + if (child.dataset.file === name) { + child.classList.remove('hidden'); + } else { + child.classList.add('hidden'); + } + } + } +}; + +document.addEventListener('DOMContentLoaded', () => { + const files = document.querySelectorAll('.mdbook-trunk-file'); + for (const file of files) { + file.addEventListener('click', () => { + if (!(file instanceof HTMLElement)) { + return; + } + + if (!file.parentElement || !file.parentElement.parentElement) { + return; + } + + const container = file.parentElement.parentElement; + const name = file.dataset.file; + + changeTrunkFile(container, file.classList.contains('active') ? null : name); + }); + } +});