@e2agency/ea-fluid-adaptability
v1.1.2
Published
The `@e2agency/ea-fluid-adaptability` package provides a set of SCSS mixins and functions for easy handling of adaptive font and element size changes on a web page.
Downloads
22
Readme
@e2agency/ea-fluid-adaptability
Description
The @e2agency/ea-fluid-adaptability
package provides a set of SCSS mixins and functions for easy handling of adaptive font and element size changes on a web page.
Docs
You can find the full and detailed documentation here.
Examples
- Basic usage
Installation
Install the package using npm:
npm install @e2agency/ea-fluid-adaptability
Usage
- Import the package into your SCSS files:
@use "@e2agency/ea-fluid-adaptability" as *;
- Set
font-size
to html usingea-clamp()
:
html {
font-size: ea-clamp(10, 16, 1200, 1920); // clamp(10px, 0px + 0.8333333333vw, 16px)
}
- Define container size using
ea-clamp()
:
.container {
max-width: ea-clamp(320, 1680, 360, 1920); // clamp(320px, 6.1538461538px + 87.1794871795vw, 1680px)
}
- Use the
ea-rem
andea-rem-max
functions for working with sizes in rem:
body {
font-size: ea-rem-max(16); // max(1rem, 14px)
}
.section {
padding: ea-rem(80) 0; // 5rem 0
}
Relative sizes
Define css-variable --ea-font-size
using ea-clamp()
and use the ea-rem
and ea-rem-max
functions for working with relative sizes:
:root {
--ea-font-size: #{ea-clamp(10.7, 16, 1280, 1920)}; // clamp(10.7px, 0.1px + 0.828125vw, 16px)
}
body {
font-size: ea-rel-max(16); // max(calc(16 * var(--ea-font-size, 16px) / 16), 14px)
}
.section {
padding: ea-rel(80) 0; // calc(80 * var(--ea-font-size, 16px) / 16) 0
}
API
See the API documentation for API of functions.
License
MIT License
Copyright (c) 2023 Egorov Agency
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.