Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat: Add Style API #111

Closed
wants to merge 1 commit into from
Closed

feat: Add Style API #111

wants to merge 1 commit into from

Conversation

cleitonper
Copy link
Contributor

@cleitonper cleitonper commented Jul 11, 2019

Style API ✨

Style API
Default Style | Dark Mode

Changes proposed

Provide a default style to unform components and a way to customize it's style
with css custom properties and styled-components.

With the changes proposed by this PR, you'll be able to use stylezed components with a beatiful apparence. To get started import the input elements from @rocketseat/unform/styled:

// Other dependencies ...
import { Form } from '@rocketseat/unform';
import { Input, FileInput, Select } from '@rocketseat/unform/styled'; // <-- Attention here

function MyAwesomeForm() {
  return (
    <Form>
      <Input 
        name="name"
        label="Name"
        placeholder="Your name"
      />
      <Input
        multiline
        name="profile"
        label="Profile"
        placeholder="Talk about you"
      />
      <Select
        name="gender"
        label="Gender"
        placeholder="Select..."
        options={[
          { id: 'male', title: 'Male' },
          { id: 'female', title: 'Female' },
        ]}
      />
    </Form>
  );
}

You can also customize your form with css custom properties

const MyAwesomeStyledForm = styled(MyAwesomeForm)`
  --border-color: #512DA8;
  --placeholder-color: rgba(150, 150, 150, 0.85);
  --error-color: #E53935; // <-- Issue #49 request
`;

Additional context

Breaking changes

BREAKING CHANGE: All input elements are now wrapped with a div element

Related issues

Related to #48 and #49.

Screenshots

Without Style
no-style
Default Style
Default Style
Focus Style
Focus Style
With Error
With Error
With Content
With Content
Disabled Style
Disabled Style
File Input: No File | Single File | Many Files
With no File
With a Single File
With many Files
Dark Mode Example
dark-mode

TODO

  • Implementation
  • Request code review
  • Docs

Provide a default style and a way to customize the unform components
with css properties.

Related to #48 and #49.
@cleitonper
Copy link
Contributor Author

Hi @diego3g, is it something that we can include in the unform?

@diego3g
Copy link
Contributor

diego3g commented Jul 16, 2019

@cleitonper First of all, great work! That's beautiful. I think we should have an easy way to add standard styles to Unform components, but i don't know if the best idea is to keep this inside the same unform repository.

I was thinking about maybe creating one package named rocket-ui that includes unform and have all the styles based on Rocketseat interface guidelines, what you think?

If you find it cool and want to contribute i can send you all the information :)

If not, we can still discuss about implementing these styles :)

@cleitonper
Copy link
Contributor Author

First of all, great work! That's beautiful.

Thanks man.

I was thinking about maybe creating one package named rocket-ui that includes unform and have all the styles based on Rocketseat interface guidelines, what you think?

I agree with the rocket-ui idea. Keeping the core of the unform together with a ui library bring us some drawbacks. One of then is the fact of we need to add dependencies that not are related to unform core.

Make the rocket-ui a open source project and the PRs will come.

@converge
Copy link

rocket-ui approach is perfect! using templates/themes is a nice option, but I believe most people won't use it. And, less code to maintain, is better for a project that is in it's begining.

@diego3g
Copy link
Contributor

diego3g commented Jul 26, 2019

I'll close this PR for now, we are working in Rocket UI and soon it will be available for the community. BTW thanks for you contribution @cleitonper! 🎉

@diego3g diego3g closed this Jul 26, 2019
@pellizzetti pellizzetti changed the title [Feature] Add Style API feat: Add Style API Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants