Skip to content

Better flow support? #570

@DarrylD

Description

@DarrylD

Based on #240

Currently something like this works

/* @flow */
import React from 'react';
import styled from 'styled-components';

type Props = {
  bold?: bool,
};

const Text = styled.span`
  color: ${props => props.theme.colors.black};
  font-family: ${props => props.theme.fontFamily};
  font-size: ${props => props.theme.fontSize.text};
  font-weight: ${props => props.bold ? props.theme.fontWeight : 'normal'};
  line-height: ${props => props.theme.lineHeight};
`;

export default (props: Props) => <Text {...props} />;

Would it be better if we could do something like so?

Props = {
  bold?: bool,
};

const default Text = styled.span(Props)`
  color: ${props => props.theme.colors.black};
  ...
`;

//or

const default Text = styled.span({bold?: bool})`
    color: ${props => props.theme.colors.black};
  ...
`;

Just kinda annoying to make another stateless. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions