Are we Design Tokens yet?

browser/components/widgets/content/widget-composer.css

Propagation: 93.75%

Back to Home
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

:host {
  --widget-composer-background-color: var(--input-background-color);
  --widget-composer-inactive-background-color: var(--input-background-color);
  --widget-composer-border-color: var(--input-border-color);
  --widget-composer-border-gradient: none;
  --widget-composer-glow-color: transparent;
  --widget-composer-outline-color: var(--focus-outline-color);
  --widget-composer-outline-offset: var(--focus-outline-offset);

  @media not (prefers-contrast) {
    --widget-composer-border-color: transparent;
    --widget-composer-border-gradient: linear-gradient(95deg, var(--color-violet-50) 1.22%, var(--color-pink-40) 49.98%, var(--color-yellow-30) 99.68%);
    --widget-composer-outline-color: light-dark(var(--color-violet-60), var(--color-violet-30));
    --widget-composer-outline-offset: var(--focus-outline-inset);
  }

  @media not (forced-colors) {
    --widget-composer-background-color: light-dark(white, var(--color-violet-110));
    --widget-composer-inactive-background-color: color-mix(in srgb, var(--widget-composer-background-color) 95%, var(--color-white));
    --widget-composer-glow-color: color-mix(in srgb, var(--color-violet-40) 50%, transparent);
    --widget-composer-selection-color: light-dark(var(--color-violet-0), var(--color-violet-60));
  }

  display: flex;
  flex-direction: column;
  font-size: var(--font-size-root);
}

.tip {
  --promo-border-color-vibrant: color-mix(in lch, currentColor 12%, transparent);
  --font-size-heading-medium: 1em;
  font-size: var(--font-size-small);
  margin-block-end: var(--space-xxlarge);

  @media (prefers-contrast) {
    --promo-border-color-vibrant: var(--border-color);
  }

  @media (forced-colors) {
    --promo-background-color-vibrant: var(--background-color-canvas);
    --promo-message-text-color-vibrant: var(--text-color);
  }
}

.tip > img[slot="image"] {
  inline-size: var(--icon-size);
  block-size: var(--icon-size);
  align-self: start;
  -moz-context-properties: fill;
  fill: currentColor;
}

.tip-body {
  & ul {
    margin-block: 0;
    padding-inline-start: var(--space-large);
  }

  & p {
    margin-block: 0;
  }
}

.examples {
  display: grid;
  grid-template-rows: 1fr;
}

.examples-list {
  min-block-size: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--space-medium) + var(--space-xxsmall));
  padding-block: var(--space-small) var(--space-xxlarge);
  padding-inline: var(--space-small);
}

.examples-intro {
  margin: 0;
  color: var(--text-color-deemphasized);
  font-size: var(--font-size-small);
}

/* These pills are similar to the Smart Window prompt pills in
 * smartwindow-prompts.css, with a few differences: the text color and padding
 * come from moz-button, there is no hover, focus or active gradient, and
 * forced colors get plain buttons. Compare the two if they are made reusable. */
.example {
  --button-content-alignment: start;
  --button-font-size: 1em;
  --button-font-weight: var(--font-weight);
}

.example::part(button) {
  text-align: start;
}

@media not (forced-colors) {
  /* stylelint-disable stylelint-plugin-mozilla/use-design-tokens, stylelint-plugin-mozilla/no-base-design-tokens */
  .example {
    --prompt-background-color: light-dark(white, var(--color-gray-70));
    --button-background-color: var(--prompt-background-color);
    --button-border-radius: var(--border-radius-circle);
  }

  .example::part(button) {
    position: relative;
    border-color: transparent;
    box-shadow: none;
  }

  .example::part(button)::before {
    content: "";
    position: absolute;
    inset: calc(-1 * var(--border-width));
    border-radius: inherit;
    padding: var(--border-width);
    background: linear-gradient(180deg, var(--prompt-background-color) 60%, var(--color-violet-30) 100%);
    mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
  }
  /* stylelint-enable stylelint-plugin-mozilla/use-design-tokens, stylelint-plugin-mozilla/no-base-design-tokens */
}

.examples[concealed] {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;

  .examples-list {
    padding-block: 0;
  }
}

@media not (prefers-reduced-motion) {
  .examples {
    transition:
      grid-template-rows 0.4s ease-out,
      opacity 0.4s ease-out,
      visibility 0.4s ease-out;
  }

  .examples-list {
    transition: padding-block 0.4s ease-out;
  }

  .tip {
    transition:
      opacity 0.2s ease-out 0.4s,
      transform 0.3s ease-out 0.4s;

    @starting-style {
      opacity: 0;
      transform: translateY(calc(100% + var(--space-xxlarge)));
    }
  }
}

.field {
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  border-radius: var(--border-radius-large);
}

@media -moz-pref("browser.nova.enabled") {
  .field {
    border-radius: var(--border-radius-xlarge);
  }
}

.background {
  position: absolute;
  inset: 0;
  border: var(--border-width) solid var(--widget-composer-border-color);
  border-radius: inherit;
  background-color: var(--widget-composer-inactive-background-color);
  transition: background-color 0.2s ease-in;

  &::after {
    content: "";
    position: absolute;
    /* stylelint-disable-next-line stylelint-plugin-mozilla/use-design-tokens */
    inset: calc(-1 * var(--border-width));
    border-radius: inherit;
    background: var(--widget-composer-border-gradient);
    mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    mask-composite: exclude;
    /* stylelint-disable-next-line stylelint-plugin-mozilla/use-design-tokens */
    padding: var(--border-width);
    pointer-events: none;
  }

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    filter: blur(10px);
    background-color: var(--widget-composer-glow-color);
  }
}

.field:is(:hover, :focus-within) > .background {
  background-color: var(--widget-composer-background-color);
  transition: background-color 0.2s ease-out;
}

.field[focused] > .background {
  outline: var(--focus-outline-width) solid var(--widget-composer-outline-color);
  outline-offset: var(--widget-composer-outline-offset);

  &::after {
    display: none;
  }
}

.chips,
textarea,
.actions {
  position: relative;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xsmall);
  margin: var(--space-medium) var(--space-large) 0;
}

textarea {
  resize: none;
  field-sizing: content;
  /* stylelint-disable-next-line stylelint-plugin-mozilla/use-design-tokens */
  min-block-size: 2lh;
  /* stylelint-disable-next-line stylelint-plugin-mozilla/use-design-tokens */
  max-block-size: 8lh;
  margin: var(--space-medium) var(--space-large) 0;
  padding: var(--space-xsmall);
  border: none;
  background: none;
  color: var(--input-text-color);
  font: inherit;
  outline: none;

  &::placeholder {
    color: var(--text-color-deemphasized);
  }

  @media not (forced-colors) {
    &::selection {
      background-color: var(--widget-composer-selection-color);
    }
  }
}

.actions {
  display: flex;
  align-items: center;
  padding: var(--space-xsmall) var(--space-large) var(--space-large);
}

.submit {
  margin-inline-start: auto;
}

.disclaimer {
  margin-block: var(--space-medium) 0;
  margin-inline: var(--space-small);
  color: var(--text-color-deemphasized);
  font-size: var(--font-size-small);
}
Back to Home