Giter Club home page Giter Club logo

Comments (7)

viktoria-schwarz avatar viktoria-schwarz commented on August 28, 2024 1

From a user perspective I'd find it easiest if we can use it like

<Button icon="Facebook" variant="primary.small">
	Buttontext
</Button>

and the icon automatically appears in the size mentioned in the button variant. Depending on the button variant, the icon is rendered in the respective color like Toshi mentioned :)

from marigold.

ti10le avatar ti10le commented on August 28, 2024

Hey @sebald @viktoria-schwarz do you have ideas how to implement the icon button?

In my opinion there are two parts but I can't stuck them together.

  • On one side we have the theme where we can add the icon params (x/y padding etc.) like 'primary.large.icon'.
  • On the other hand we have the icon. How to add the to the button component?

We could do something like this:

<Button variant="primary.small.icon">
   <Ticket /> Primary
 </Button> 

But then the user have to look about the variant with icon param and have to add the icon themselve. Is there an easier way? And I dont know if this would work πŸ˜„

from marigold.

ti10le avatar ti10le commented on August 28, 2024

image

At the moment this is the reason if we type this:

<Button variant="primary.small">
  <Ticket /> Primary
</Button>

from marigold.

ti10le avatar ti10le commented on August 28, 2024

First I try to write a test :) But this is a good approach.

from marigold.

viktoria-schwarz avatar viktoria-schwarz commented on August 28, 2024

Another idea (and maybe easier to implement) would be like this:

<Button variant="primary.small">
	<Facebook />
	<Text> blabla </Text>
</Button>

and adjust the Button and its children for spacings and alignment like

<Box as="button" themeSection="button" variant={variant} {...props}>
    <span style={{ display: 'inline-flex', alignItems: 'center' }}>
        {children}
    </span>
</Box>

with respective additions in the theme (add 'inline-flex' to button.root and a marginRight to the Svg).

Added a first idea of it in #284

from marigold.

ti10le avatar ti10le commented on August 28, 2024

This is a good method! But this two aspects are important, too. (Maybe later)

  • Maybe we have to find a solution for the small button default size. Default size is 24px. Small button should have 20px.
  • If a button has an icon, padding-left should be: button.small: 12px instead of 16 and button.large: 24px instead of 32. But how to say to the button that he has an icon?

from marigold.

sebald avatar sebald commented on August 28, 2024

There is no silver bullet for this. There are many different implementations for this. My suggestion:

In order to preserve composability and allow for extension: don’t use an icon prop on the button. The button should not have to know anything about its children.

You can fix the alignment with flexbox. πŸ™‚

from marigold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.