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

Dynamic inline-styles for buttons(tiles) #939

Open
1 task done
BrianWahinya opened this issue May 9, 2024 · 3 comments
Open
1 task done

Dynamic inline-styles for buttons(tiles) #939

BrianWahinya opened this issue May 9, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@BrianWahinya
Copy link

BrianWahinya commented May 9, 2024

Before you start - checklist

  • I have checked if this feature request is not already reported

Description

I would like to add dynamic inline-styling to a specific tile/button without assigning a className or changing tileContent.
In React it is possible to do this:

const userColor = getUserInput()
return <>
  <button>10<button>
  <button style={{ backgroundColor: userColor}}>11<button>
  <button>12<button>
</>

Assigning a tileClassName isn't sufficient because you need to already have defined the colors in an external CSS file for that particular class. This isn't dynamic.
My goal is to let the user decide the color of a particular tile from a color-palette within the program.

Proposed solution

Similar to how we assign a className using tileClassName, there can be a method such as tileStyle to handle inline styling.

  const tileStyle= ({ date }) => {
      if(compare(date, targetDate)){
        return {
          backgroundColor: "#000",
          fontSize: "15px"
        }
      }
  }

 return <ReactCalendar tileStyle={tileStyle} />

Alternatives

No response

Additional information

No response

@BrianWahinya BrianWahinya added the enhancement New feature or request label May 9, 2024
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Aug 12, 2024
Copy link
Contributor

github-actions bot commented Sep 2, 2024

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
@wojtekmaj
Copy link
Owner

A much more maintainable approach would be to either create a generic tileProps function, or a renderTile function that would let override the default tile rendering logic.

@wojtekmaj wojtekmaj reopened this Sep 2, 2024
@wojtekmaj wojtekmaj removed the stale label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants