Skip to content

fix: #1065 Add custom values to slider#1225

Merged
mscolnick merged 8 commits into
mainfrom
unknown repository
Apr 26, 2024
Merged

fix: #1065 Add custom values to slider#1225
mscolnick merged 8 commits into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Apr 25, 2024

Copy link
Copy Markdown
Screenshot 2024-04-25 at 19 02 47

@vercel

vercel Bot commented Apr 25, 2024

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 9:41am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 9:41am

Comment thread frontend/package.json
"lodash-es": "^4.17.21",
"lucide-react": "^0.338.0",
"lz-string": "^1.5.0",
"mathjs": "^12.4.2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think youll want to run pnpm install in cd frontend, and commit the changes to the lockfile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can remove this with the suggestion below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the lockfile, but don't know whether it's right


return Math.trunc(value) === 0
? // No integer part, use scientific notation
format(value, { notation: "auto", precision: 2 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the browser has this built in now. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#scientific

would that work instead and avoid the extra dep? we can lowercase the e aswell to match this formatting.

new Intl.NumberFormat("en-US", {
  notation: "scientific",
}).format(987654321);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a bug for this, the slider would disappear after some dragging, so I retain to mathjs

assert "Invalid bounds" in str(e.value)


def test_slider_exclusive_args() -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for empty steps (not sure how we want to handle) and invalid bounds (value is not in steps)

# cast to floats
assert isinstance(num, float)

slider = ui.range_slider(steps=[1, 3, 6, 10, 17, 20], value=[3, 17])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for empty steps (not sure how we want to handle) and invalid bounds (value is not in steps)

@mscolnick mscolnick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! this is really great

@mscolnick
mscolnick merged commit 6589e3f into marimo-team:main Apr 26, 2024
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.4.6-dev4

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.

1 participant