diff --git a/.DS_Store b/.DS_Store index c88a062..cd97d06 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..cea0971 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [elchininet] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..93b1090 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + commit-message: + prefix: "[Dependencies]" + groups: + dependencies-prod: + dependency-type: "production" + dependencies-dev: + dependency-type: "development" + labels: + - dependencies + versioning-strategy: increase diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..078a8fe --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,76 @@ +name: Create release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set-up Node + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + registry-url: 'https://registry.npmjs.org' + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cache + key: dependencies-v1-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Install deps + run: yarn install --frozen-lockfile + - name: Tests + run: yarn test:ts + - name: Build Changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v3 + with: + configurationJson: | + { + "categories": [ + { + "title": "## 🚀 Features", + "labels": ["feature", "feature-request", "enhancement", "request"] + }, + { + "title": "## 🛠 Fixes", + "labels": ["fix", "bug"] + }, + { + "title": "## 🧩 Dependencies", + "labels": ["dependencies"] + }, + { + "title": "## ⚙️ Configuration", + "labels": ["configuration"] + }, + { + "title": "## 📝 Documentation", + "labels": ["documentation"] + }, + { + "title": "## 📦 Other", + "labels": [] + } + ], + "template": "#{{CHANGELOG}}", + "pr_template": "- #{{TITLE}}\n - PR: ##{{NUMBER}} by @#{{AUTHOR}}", + "empty_template": "#{{OWNER}}\n#{{REPO}}\n#{{FROM_TAG}}\n#{{TO_TAG}}", + "max_pull_requests": 1000, + "max_back_track_time_days": 1000 + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create a release + uses: softprops/action-gh-release@v1 + with: + files: | + dist/custom-sidebar.js + body: | + ${{ steps.build_changelog.outputs.changelog }} \ No newline at end of file diff --git a/.github/workflows/hacs.yaml b/.github/workflows/hacs.yaml new file mode 100644 index 0000000..ed4d505 --- /dev/null +++ b/.github/workflows/hacs.yaml @@ -0,0 +1,18 @@ +name: HACS Action + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + hacs: + name: HACS Action + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - name: HACS Action + uses: "hacs/action@main" + with: + category: "plugin" \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..87de6e3 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cache + key: dependencies-v1-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Install + run: yarn install --frozen-lockfile + - name: Tests + run: yarn test:ts \ No newline at end of file diff --git a/README.md b/README.md index 13796db..1f9c335 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,29 @@ Custom [HACS] plugin that allows you to rearrange, hide, and add menu items to the sidebar in [Home Assistant]. + + + + + + + + + + + + + +
Default sidebarHide some itemsAdd new itemsReorder items
+ default sidebar + + hide items + + new items + + reorder items +
+ This is a refactor of [custom-sidebar-v2] by @galloween, which is now archived. Inspired in the [original Custom Sidebar] plugin by @Villhellm (R.I.P). ## Installation diff --git a/images/default-sidebar.png b/images/default-sidebar.png new file mode 100644 index 0000000..613acba Binary files /dev/null and b/images/default-sidebar.png differ diff --git a/images/hide-items.png b/images/hide-items.png new file mode 100644 index 0000000..26bd288 Binary files /dev/null and b/images/hide-items.png differ diff --git a/images/new-items.png b/images/new-items.png new file mode 100644 index 0000000..a429c19 Binary files /dev/null and b/images/new-items.png differ diff --git a/images/reorder-items.png b/images/reorder-items.png new file mode 100644 index 0000000..b6eed4d Binary files /dev/null and b/images/reorder-items.png differ diff --git a/package.json b/package.json index ac51ec3..069af3e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "license": "Apache-2.0", "private": false, "scripts": { - "build": "rollup --config rollup.config.js --bundleConfigAsCjs" + "build": "rollup --config rollup.config.js --bundleConfigAsCjs", + "test:ts": "tsc --noEmit" }, "devDependencies": { "@rollup/plugin-json": "^6.1.0", diff --git a/src/custom-sidebar.ts b/src/custom-sidebar.ts index 6dbbfcc..3647085 100644 --- a/src/custom-sidebar.ts +++ b/src/custom-sidebar.ts @@ -158,7 +158,7 @@ class CustomSidebar { ._getElementWithConfig(titleElementPromise) .then(([config, titleElement]): void => { if (config.title) { - titleElement.innerHTML = 'Fake title'; + titleElement.innerHTML = config.title; } }); } @@ -205,9 +205,8 @@ class CustomSidebar { return total; }, 0); - orderWithItems.forEach((orderItem: ConfigOrderWithItem): void => { - - if (orderItem.bottom && !crossedBottom) { + const processBottom = () => { + if (!crossedBottom) { Array.from(items).forEach((element: HTMLElement) => { if (!element.hasAttribute(ATTRIBUTE.PROCESSED)) { element.style.order = `${orderIndex}`; @@ -218,6 +217,13 @@ class CustomSidebar { orderIndex ++; crossedBottom = true; } + }; + + orderWithItems.forEach((orderItem: ConfigOrderWithItem): void => { + + if (orderItem.bottom) { + processBottom(); + } if (orderItem.new_item) { @@ -255,6 +261,8 @@ class CustomSidebar { orderIndex++; }); + + processBottom(); }); }