Skip to content

Commit

Permalink
fix: add correct gradient behavior #47 #51
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-capsule42 committed Nov 4, 2024
1 parent d6de246 commit a7eb0e5
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 42 deletions.
19 changes: 18 additions & 1 deletion demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,21 @@ Used for all elements inside the scrolling carousel.
</auro-carousel>
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>
</auro-accordion>

### Theme Support

The component may be restyled using the following code sample and changing the values of the following token(s).

<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../src/tokens.scss) -->
<!-- The below code snippet is automatically added from ./../../src/tokens.scss -->

```scss
@import './../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables';

:host {
--ds-auro-carousel-gradient-color-one: var(--ds-color-background-primary-100-default, #{$ds-color-background-primary-100-default});
--ds-auro-carousel-gradient-color-two: transparent;
}
```
<!-- AURO-GENERATED-CONTENT:END -->
44 changes: 27 additions & 17 deletions demo/api.min.js

Large diffs are not rendered by default.

44 changes: 27 additions & 17 deletions demo/index.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/partials/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,10 @@ Used for all elements inside the scrolling carousel.
<!-- AURO-GENERATED-CONTENT:END -->

</auro-accordion>

### Theme Support

The component may be restyled using the following code sample and changing the values of the following token(s).

<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../src/tokens.scss) -->
<!-- AURO-GENERATED-CONTENT:END -->
18 changes: 13 additions & 5 deletions src/auro-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-disable max-lines, lit/no-invalid-html, lit/binding-positions */

import { LitElement, css } from "lit";
import { LitElement } from "lit";
import { html } from 'lit/static-html.js';

import { classMap } from 'lit/directives/class-map.js';
Expand All @@ -25,6 +25,8 @@ import chevronRight from '@alaskaairux/icons/dist/icons/interface/chevron-right.
import chevronLeft from '@alaskaairux/icons/dist/icons/interface/chevron-left.mjs';

import styleCss from "./style-css.js";
import colorCss from "./color-css.js";
import tokensCss from "./tokens-css.js";

// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
/**
Expand Down Expand Up @@ -92,7 +94,11 @@ export class AuroCarousel extends LitElement {
}

static get styles() {
return [css`${styleCss}`];
return [
styleCss,
colorCss,
tokensCss
];
}

/**
Expand Down Expand Up @@ -376,12 +382,14 @@ export class AuroCarousel extends LitElement {
aria-roledescription="carousel"
class="${classMap(carouselClassMap)}"
@scroll=${() => this.setScrollFlags(true)} >
<${this.buttonTag} arialabel="chevron-left" iconOnly rounded variant="secondary" @click=${() => this.handleClick(false)} class="button button--left">
${this.generateIconHtml(chevronLeft.svg)}<span class="util_displayHiddenVisually">Scroll Left</span>
</${this.buttonTag}>
<div class="container">
<div class="gradient--left"></div>
<slot @slotchange=${this.handleSlotChange}></slot>
<div class="gradient--right"></div>
</div>
<${this.buttonTag} arialabel="chevron-left" iconOnly rounded variant="secondary" @click=${() => this.handleClick(false)} class="button button--left">
${this.generateIconHtml(chevronLeft.svg)}<span class="util_displayHiddenVisually">Scroll Left</span>
</${this.buttonTag}>
<${this.buttonTag} arialabel="chevron-right" iconOnly rounded variant="secondary" @click=${() => this.handleClick(true)} class="button button--right">
${this.generateIconHtml(chevronRight.svg)}<span class="util_displayHiddenVisually">Scroll Right</span>
</${this.buttonTag}>
Expand Down
22 changes: 22 additions & 0 deletions src/color.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
// See LICENSE in the project root for license information.

// ---------------------------------------------------------------------

/* stylelint-disable selector-class-pattern */

@import './../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables';

:host {
.gradient {
background: var(--ds-auro-carousel-gradient-color-two);
}

.gradient--left {
background: linear-gradient(90deg, var(--ds-auro-carousel-gradient-color-one) 0%, var(--ds-auro-carousel-gradient-color-one) 40%, var(--ds-auro-carousel-gradient-color-two) 100%);
}

.gradient--right {
background: linear-gradient(to left, var(--ds-auro-carousel-gradient-color-one), var(--ds-auro-carousel-gradient-color-two));
}
}
21 changes: 19 additions & 2 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,31 @@
right: 0;
}

[class^='gradient'] {
position: absolute;
top: 0;
width: calc(var(--ds-size-1000, $ds-size-1000) + var(--ds-size-500, $ds-size-500) + var(--ds-size-150, $ds-size-150));
height: 100%;
}

.gradient--left {
left: 0;
}

.gradient--right {
right: 0;
}

.carousel--scrolledToStart {
.button--left {
.button--left,
.gradient--left {
display: none;
}
}

.carousel--scrolledToEnd {
.button--right {
.button--right,
.gradient--right {
display: none;
}
}
7 changes: 7 additions & 0 deletions src/tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import './../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables';

:host {
--ds-auro-carousel-gradient-color-one: var(--ds-color-background-primary-100-default, #{$ds-color-background-primary-100-default});
--ds-auro-carousel-gradient-color-two: transparent;
}

0 comments on commit a7eb0e5

Please sign in to comment.