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

Visually render the Progress max prop #492

Merged
merged 1 commit into from
May 9, 2024

Conversation

masenf
Copy link
Contributor

@masenf masenf commented May 8, 2024

Thanks for providing radix themes, it's been a joy working with this package. This is my first PR here, so please let me know if I'm missing anything.

Description

When rendering the Progress component, calculate the transform scaleX of the Progress.Indicator using the max prop supplied by the user.

The max prop is documented for the Progress primitive component and is used when determining the aria-valuemax and aria-valuetext attributes for the Progress div.

Testing steps

I'm using this sample app to test the change

import "@radix-ui/themes/styles.css";
import { useState } from "react";
import { Box, Flex, Progress, Slider, Text, Theme } from "@radix-ui/themes";

function App() {
  const [value, setValue] = useState([50]);
  const [max, setMax] = useState([100]);
  return (
    <Theme>
      <div
        style={{
          backgroundColor: "var(--accent-2)",
          minHeight: "100vh",
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
          fontSize: "calc(10px + 2vmin)",
        }}
      >
        <Flex direction={"column"} gap={"3"} style={{ width: "300px" }}>
          <Progress value={value[0]} max={max[0]} />

          <Flex gap={"2"}>
            <Box flexGrow={"1"}>
              <Text>Value {value[0]}</Text>
              <Slider value={value} onValueChange={setValue} max={300} />
            </Box>
            <Box flexGrow={"1"}>
              <Text>Max {max[0]}</Text>
              <Slider value={max} onValueChange={setMax} max={300} />
            </Box>
          </Flex>
        </Flex>
      </div>
    </Theme>
  );
}

export default App;
Screen.Recording.2024-05-08.at.13.04.30.mov

Relates issues / PRs

None seen.

Copy link

vercel bot commented May 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
themes-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2024 4:36pm

masenf added a commit to reflex-dev/reflex that referenced this pull request May 8, 2024
It doesn't work yet, but PR filed for radix-ui/themes:
radix-ui/themes#492
masenf added a commit to reflex-dev/reflex that referenced this pull request May 8, 2024
* radix themes progress: expose `max` prop

It doesn't work yet, but PR filed for radix-ui/themes:
radix-ui/themes#492

* Move `progress` and `toast` to `_x`

[REF-2779] Expose skeleton and data_list in top level namespace.
@vladmoroz
Copy link
Contributor

Thanks for the contribution!

Before merging, could you also add the following entry to changelog.md?

## 3.0.4 (unreleased)

- Support the `max` prop on the `Progress` component

When rendering the Progress component, calculate the transform scaleX of the
Progress.Indicator using the `max` prop supplied by the user.

The `max` prop is documented for the Progress primitive component and is used
when determining the `aria-valuemax` and `aria-valuetext` attributes for the
Progress div.
@masenf masenf force-pushed the support-progress-max-prop branch from fb0b331 to 75094e4 Compare May 9, 2024 16:35
@vladmoroz vladmoroz merged commit 3edd166 into radix-ui:main May 9, 2024
2 checks passed
@masenf masenf deleted the support-progress-max-prop branch May 9, 2024 18:48
@vladmoroz
Copy link
Contributor

@masenf this was released as part of "@radix-ui/themes": "3.0.4"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants