Skip to content

Custom element for use as a way to show an image or background color around a block of code or in a slot when used in conjuction with other web components like `auro-banner`.

License

Notifications You must be signed in to change notification settings

AlaskaAirlines/auro-background

Background

The auro-background element is an easy-to-use mobile-first alternative to writing custom CSS for background colors or images with automatically scoped media queries. Use independently or in the slot of another custom element such as auro-banner.

UI development browser support

For the most up to date information on UI development browser support

Install

Build Status See it on NPM! License ESM supported

$ npm i @aurodesignsystem/auro-background

Design Token CSS Custom Property dependency

The use of any Auro custom element has a dependency on the Auro Design Tokens.

Define dependency in project component

Defining the component dependency within each component that is using the <auro-background> component.

import "@aurodesignsystem/auro-background";

Reference component in HTML

<auro-background bg="url(https://images.contentstack.io/v3/assets/blt2cefe12c88e9dd91/blt4dde4105498391f8/6633c2581dbb0973c00b8783/ad2.png) center center/cover no-repeat">
  <div style="color: var(--ds-color-text-primary-inverse); display: flex; flex-direction: column; align-items: center; justify-content: center;">
    <auro-header level="2" display="600">View all destinations</auro-header>
    <auro-hyperlink cta href="#">See where we fly</auro-hyperlink>
  </div>
</auro-background>

Use CDN

In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.

<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-background@latest/+esm"></script>

auro-background use cases

The auro-background component accepts 4 properties - bg, height, width, and inset that serve as the default at all breakpoints. height, width, and inset are not required and sizing will scale to the content when omitted. Additionally, there is a separate property for each supported breakpoint (bgsm, bgmd, bglg, heightsm, heightmd, heightlg, widthsm, widthmd, widthlg). If you don't set specific size property the smaller property will be used.

These properties map to the compound CSS background property and CSS properties of height, width, and padding. Anything you can do within the scope of those CSS rules you can do here.

See CSS Background Image Generator for a helpful code generation tool.

API Code Examples

Default auro-background

<auro-background bg="url(https://images.contentstack.io/v3/assets/blt2cefe12c88e9dd91/blt4dde4105498391f8/6633c2581dbb0973c00b8783/ad2.png) center center/cover no-repeat">
  <div style="color: var(--ds-color-text-primary-inverse); display: flex; flex-direction: column; align-items: center; justify-content: center;">
    <auro-header level="2" display="600">View all destinations</auro-header>
    <auro-hyperlink cta href="#">See where we fly</auro-hyperlink>
  </div>
</auro-background>

Development

In order to develop against this project, if you are not part of the core team, you will be required to fork the project prior to submitting a pull request.

Please be sure to review the contribution guidelines for this project. Please make sure to pay special attention to the conventional commits section of the document.

Start development environment

Once the project has been cloned to your local resource and you have installed all the dependencies you will need to open a shell session to run the dev server.

$ npm run dev

Open localhost:8000

Testing

Automated tests are required for every Auro component. See .\test\auro-background.test.js for the tests for this component. Run npm run test to run the tests and check code coverage. Tests must pass and meet a certain coverage threshold to commit. See the testing documentation for more details.

About

Custom element for use as a way to show an image or background color around a block of code or in a slot when used in conjuction with other web components like `auro-banner`.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 13