Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda