Skip to content

Commit

Permalink
Merge pull request #124 from palcarazm/palcarazm/issue123
Browse files Browse the repository at this point in the history
fix: Doesn't size to text
  • Loading branch information
palcarazm committed Apr 7, 2023
2 parents d87ef60 + 5f9d5fc commit 9baee11
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 287 deletions.
244 changes: 0 additions & 244 deletions CHANGELOG.md

This file was deleted.

15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![NPM Badge](https://img.shields.io/npm/dm/bootstrap5-toggle?logo=npm)](https://www.npmjs.com/package/bootstrap5-toggle)
[![Build](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/build.yml?branch=v5&logo=npm)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Build+Check%22)
[![Test](https://img.shields.io/github/actions/workflow/status/palcarazm/bootstrap5-toggle/cypress.yml?branch=v5&label=tests&logo=cypress)](https://github.com/palcarazm/bootstrap5-toggle/actions?query=workflow%3A%22Cypress+Tests%22)
[![Security](https://img.shields.io/snyk/vulnerabilities/npm/bootstrap5-toggle@5.0.4?logo=snyk)](https://snyk.io/advisor/npm-package/bootstrap5-toggle)
[![Security](https://img.shields.io/snyk/vulnerabilities/npm/bootstrap5-toggle@5.0.6?logo=snyk)](https://snyk.io/advisor/npm-package/bootstrap5-toggle)
[![EOL](https://img.shields.io/endpoint?url=https%3A%2F%2Fpalcarazm.github.io%2Fbootstrap5-toggle%2Fapi%2Feol%2Fv5)](https://github.com/palcarazm/bootstrap5-toggle/security/policy)
[![Funding](https://img.shields.io/badge/sponsor-30363D?style=flat&logo=GitHub-Sponsors&logoColor=#white)](https://github.com/sponsors/palcarazm)
[![Rate this package](https://badges.openbase.com/js/rating/bootstrap5-toggle.svg?token=rNvznTVToo+EmX5g+KTvfYqI9+YTWJeUWTxPj7tLA6o=)](https://openbase.com/js/bootstrap5-toggle?utm_source=embedded&utm_medium=badge&utm_campaign=rating-badge&utm_term=js/bootstrap5-toggle)
Expand Down Expand Up @@ -45,7 +45,6 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Installation](#installation)
- [CDN](#cdn)
- [ECMAS Interface](#ecmas-interface)
Expand Down Expand Up @@ -79,18 +78,18 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/

```html
<link
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.4/css/bootstrap5-toggle.min.css"
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.6/css/bootstrap5-toggle.min.css"
rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.4/js/bootstrap5-toggle.ecmas.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.6/js/bootstrap5-toggle.ecmas.min.js"></script>
```

### jQuery Interface

```html
<link
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.4/css/bootstrap5-toggle.min.css"
href="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.6/css/bootstrap5-toggle.min.css"
rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.4/js/bootstrap5-toggle.jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap5-toggle@5.0.6/js/bootstrap5-toggle.jquery.min.js"></script>
```

## Download
Expand All @@ -102,13 +101,13 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/
[![NPM Badge](https://img.shields.io/npm/dm/bootstrap5-toggle?logo=npm)](https://www.npmjs.com/package/bootstrap5-toggle)

```ksh
npm install bootstrap5-toggle@5.0.4
npm install bootstrap5-toggle@5.0.6
```

## Yarn

```ksh
yarn add bootstrap5-toggle@5.0.4
yarn add bootstrap5-toggle@5.0.6
```

# Usage
Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap5-toggle.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright Notice
* bootstrap5-toggle v5.0.4
* bootstrap5-toggle v5.0.6
* https://palcarazm.github.io/bootstrap5-toggle/
* @author 2011-2014 Min Hur (https://github.com/minhur)
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap5-toggle.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/bootstrap5-toggle.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 17 additions & 12 deletions js/bootstrap5-toggle.ecmas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright Notice
* bootstrap5-toggle v5.0.4
* bootstrap5-toggle v5.0.6
* https://palcarazm.github.io/bootstrap5-toggle/
* @author 2011-2014 Min Hur (https://github.com/minhur)
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
Expand Down Expand Up @@ -259,22 +259,27 @@
{
// A: Set style W/H
// NOTE: `offsetWidth` returns *rounded* integer values, so use `getBoundingClientRect` instead.
ecmasToggle.style["min-width"] = `${
Math.max(
ecmasToggleOn.getBoundingClientRect().width,
ecmasToggleOff.getBoundingClientRect().width
) +
ecmasToggleHandle.getBoundingClientRect().width / 2
}px`;
if (this.options.width) {
ecmasToggle.style.width = `${this.options.width}px`;
} else {
ecmasToggle.style["min-width"] = "100px"; // First approach for better calculation
ecmasToggle.style["min-width"] = `${
Math.max(
ecmasToggleOn.getBoundingClientRect().width,
ecmasToggleOff.getBoundingClientRect().width
) +
ecmasToggleHandle.getBoundingClientRect().width / 2
}px`;
}
ecmasToggle.style["min-height"] = `${Math.max(
ecmasToggleOn.getBoundingClientRect().height,
ecmasToggleOff.getBoundingClientRect().height
)}px`;

if (this.options.height) {
ecmasToggle.style.height = `${this.options.height}px`;
} else {
ecmasToggle.style["min-height"] = "36px"; // First approach for better calculation
ecmasToggle.style["min-height"] = `${Math.max(
ecmasToggleOn.getBoundingClientRect().height,
ecmasToggleOff.getBoundingClientRect().height
)}px`;
}

// B: Apply on/off class
Expand Down
Loading

0 comments on commit 9baee11

Please sign in to comment.