Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
How to add an independent function to storybook's project

I'm starting to integrate storybook to our application, and one of the things I would like to achieve is this: We have a dark and light theme, which via sass changes a css variables accordingly:

.dark-theme {
  @include theme-colors(true);
}

and: 
@mixin theme-colors($dark-theme) {
  --wc-black-to-white-alpha-7: #{if($dark-theme, $white-alpha-7, $black)};

Normaly, we have a service which responsible of this logic, but the UI component does not inject it by itself. Now I was wondering if there's a way to use a function, which is not part of the specific component, to do something like that. I've tried looking at "storybook-dark-mode" (https://storybook.js.org/addons/storybook-dark-mode) which got me the point where I can add a "dark-theme" class to the document of storybook, but not in the app itself (inside the iframe). Is it possible doing something like this:

import { CommonModule } from '@angular/common';
import { componentWrapperDecorator, Meta, moduleMetadata, Story } from '@storybook/angular';
import { chipStyles } from '@wc/wc-models/src/lib/enums/general';
import { WcChipComponent } from './wc-chip.component';

const styleValues = Object.values(chipStyles);

function toggleDarkTheme() {
 add the .dark-theme class here.
}

export default {
  title: 'wc-chip',
  component: WcChipComponent,
  argTypes: {
    style: {
      options: styleValues,
      control: { type: 'select' },
    },
    _chipClicked: { action: 'clicked' },
  },
 ..........

and use toggleDarkTheme in the story somehow?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda