Skip to content

Commit

Permalink
feat: add rdp-range_middle-color CSS variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Jul 13, 2024
1 parent d462152 commit f8e835a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

--rdp-range_middle-background-color: var(--rdp-accent-background-color); /* The color of the background for days in the middle of a range. */
--rdp-range_middle-font: normal medium var(--rdp-font-family); /* The font for days in the middle of a range. */
--rdp-range_middle-foreground-color: white; /* The font for days in the middle of a range. */
--rdp-range_middle-color: inherit;/* The color of the range text. */

--rdp-range_start-color: white; /* The color of the range text. */
--rdp-range_start-background: linear-gradient(var(--rdp-gradient-direction), transparent 50%, var(--rdp-range_middle-background-color) 50%); /* Used for the background of the start of the selected range. */
Expand Down Expand Up @@ -315,6 +317,7 @@
border-color: transparent;
border: unset;
border-radius: unset;
color: var(--rdp-range_middle-color);
}

.rdp-range_end {
Expand Down
4 changes: 4 additions & 0 deletions src/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

--rdp-range_middle-background-color: var(--rdp-accent-background-color); /* The color of the background for days in the middle of a range. */
--rdp-range_middle-font: normal medium var(--rdp-font-family); /* The font for days in the middle of a range. */
--rdp-range_middle-foreground-color: white; /* The font for days in the middle of a range. */
--rdp-range_middle-color: inherit;/* The color of the range text. */

--rdp-range_start-color: white; /* The color of the range text. */
--rdp-range_start-background: linear-gradient(var(--rdp-gradient-direction), transparent 50%, var(--rdp-range_middle-background-color) 50%); /* Used for the background of the start of the selected range. */
Expand Down Expand Up @@ -315,6 +317,7 @@
border-color: transparent;
border: unset;
border-radius: unset;
color: var(--rdp-range_middle-color);
}

.range_end {
Expand All @@ -332,5 +335,6 @@
}

.day_button:focus-visible {
/* outline: 2px solid var(--rdp-accent-color); */
/* You may want to add focus-outlines here. */
}
1 change: 1 addition & 0 deletions website/docs/docs/styling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following table lists the CSS variables used by DayPicker inside the `.rdp-r
| `--rdp-nav-height` | The height of the navigation bar. |
| `--rdp-range_middle-background-color` | The color of the background for days in the middle of a range. |
| `--rdp-range_middle-font` | The font for days in the middle of a range. |
| `-- ` | The color of the text for days in the middle of a range. |
| `--rdp-range_start-color` | The color of the range text at the start of the range. |
| `--rdp-range_start-background` | Used for the background of the start of the selected range. |
| `--rdp-range_start-date-background-color` | The background color of the date at the start of the selected range. |
Expand Down
33 changes: 23 additions & 10 deletions website/src/pages/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ export default function Playground() {
const [utc, setUtc] = React.useState(false);

const [accentColor, setAccentColor] = React.useState<string>();
const [backgroundAccentColor, setAccentBackgroundColor] =
const [backgroundAccentColor, setBackgroundAccountColor] =
React.useState<string>();
const [rangeMiddleColor, setrangeMiddleColor] = React.useState<string>();

const Component = utc ? DayPickerUtc : DayPicker;
const formattedProps = `<DayPicker${toJSX({ ...props, locale: undefined })} />`;
Expand All @@ -69,6 +70,7 @@ export default function Playground() {
[data-theme="dark"] .rdp-root {
${accentColor ? `--rdp-accent-color: ${accentColor} !important` : ""};
${backgroundAccentColor ? `--rdp-accent-background-color: ${backgroundAccentColor} !important` : ""};
${rangeMiddleColor ? `--rdp-range_middle-color: ${rangeMiddleColor} !important` : ""};
}
`}
</style>
Expand Down Expand Up @@ -406,15 +408,26 @@ export default function Playground() {
</label>
) : null}
{props.mode === "range" && (
<label>
Range Color:
<input
value={backgroundAccentColor ?? ""}
type="color"
name="numberOfMonths"
onChange={(e) => setAccentBackgroundColor(e.target.value)}
/>
</label>
<>
<label>
Range Background:
<input
value={backgroundAccentColor ?? ""}
type="color"
onChange={(e) =>
setBackgroundAccountColor(e.target.value)
}
/>
</label>
<label>
Range Foreground:
<input
value={rangeMiddleColor ?? ""}
type="color"
onChange={(e) => setrangeMiddleColor(e.target.value)}
/>
</label>
</>
)}
</div>
</fieldset>
Expand Down

0 comments on commit f8e835a

Please sign in to comment.