Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] - Allow Override of Inline Styles in Components #51

Open
phongnguyen-it opened this issue Aug 26, 2024 · 1 comment
Open

[UI] - Allow Override of Inline Styles in Components #51

phongnguyen-it opened this issue Aug 26, 2024 · 1 comment

Comments

@phongnguyen-it
Copy link

Title: [UI] - Allow Override of Inline Styles in Components

Description:

Currently, the component uses hardcoded inline styles like the following:

<div style={{ border: '1px solid #bebebe' }}>
  <div style={{ margin: '16px 16px 0 16px', overflow: 'auto', paddingBottom: '16px' }}>

This makes it difficult to apply custom styles that align with our design system tokens. I need the ability to override these inline styles to ensure consistency with our design guidelines.

Please consider adding support for style overrides, possibly through props or by removing inline styles, to allow greater flexibility in styling components.

Thank you for your assistance!

@phongnguyen-it
Copy link
Author

Currently, workaround with code:

import React, {useEffect} from 'react';
import { Playground } from 'storybook-addon-code-editor';

const LIVE_CODE_CLASS_NAME = '.sb-live-code_wrapper';
const LiveCodePlayground = (props: typeof Playground) => {

	useEffect(() => {
		const targetElement = document.querySelector(LIVE_CODE_CLASS_NAME);
		if (targetElement && targetElement.parentElement && targetElement.parentElement.parentElement) {
			const grandparent = targetElement.parentElement.parentElement;
			grandparent.style.border = '1px solid var(--border)';
			grandparent.style.borderTopLeftRadius = '8px';
			grandparent.style.borderTopRightRadius = '8px';
		}
	}, []);

	return <Playground {...props} />
};


export default LiveCodePlayground;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant