FER-028: Estilização em Componentes React

Aplicar técnicas modernas de estilização em projetos React

Props e Temas em Styled Components

💻 Exemplo: Estilos Baseados em Props

const Button = styled.button`
    background-color: ${props => 
        props.primary ? '#007bff' : '#6c757d'};
    color: white;
    padding: ${props => props.large ? '15px 30px' : '10px 20px'};
    font-size: ${props => props.large ? '18px' : '16px'};
    border: none;
    border-radius: 5px;
`;

// Uso
<Button primary>Primário</Button>
<Button large>Grande</Button>
<Button primary large>Primário Grande</Button>

💻 Exemplo: Tema Global

import { ThemeProvider } from 'styled-components';

const theme = {
    colors: {
        primary: '#007bff',
        secondary: '#6c757d',
        success: '#28a745'
    },
    spacing: {
        sm: '10px',
        md: '20px',
        lg: '40px'
    }
};

const Button = styled.button`
    background-color: ${props => props.theme.colors.primary};
    padding: ${props => props.theme.spacing.md};
`;

function App() {
    return (
        <ThemeProvider theme={theme}>
            <Button>Botão</Button>
        </ThemeProvider>
    );
}