Skip to content

Conversation

@arraydude
Copy link
Contributor

@arraydude arraydude commented Oct 15, 2019

Issue: streamlit/streamlit-old-private#767

Description:

  • New st.number_input()
  • Python unit tests
  • Jest unit tests using enzyme
  • Cypress tests

Contribution License Agreement

By submiting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@arraydude arraydude requested a review from a team as a code owner October 15, 2019 06:23
@jrhone
Copy link
Contributor

jrhone commented Oct 16, 2019

I see a cypress snapshot for darwin but one for linux is missing

@jrhone
Copy link
Contributor

jrhone commented Oct 16, 2019

Did you add the darwin snapshots by using cy:open? I see a 1x dpi in the path, frontend/cypress/snapshots/darwin/1x/number_input.spec.ts/number_input0.snap.png, but I don't think we have any other snapshots committed with 1x

EDIT: Actually it looks like the darwin snapshots are now ignored by .gitignore so not sure how you were able to commit them

# Ignore screenshots that don't get used in CircleCI
frontend/cypress/snapshots/darwin

value = 0

value = 0 if isinstance(value, NoValue) else value
int_value = isinstance(value, int)
Copy link
Contributor

@jrhone jrhone Oct 16, 2019

Choose a reason for hiding this comment

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

maybe this should be called is_int? same for float_value below

EDIT: I see you have an imported function called is_int so maybe is_int_value instead? Just a suggestion. int_value is fine too but sounds like it's the actual value instead of a boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed is_int to is_int_value, because it's checking if a given value is actually an int, here it's being used with an string which contains a number.

value = 0

value = 0 if isinstance(value, NoValue) else value
int_value = isinstance(value, int)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it ok to use isinstance here but you use the is_int helper below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is_int helper was a later change needed when i checking an str , i will change it

----------
label : str or None
A short label explaining to the user what this input is for.
value : int/float or None
Copy link
Contributor

Choose a reason for hiding this comment

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

it says int/float or None but we throw an error if they pass None I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's something tricky because we could call the function with no value which would be None but if the user passes None we need to raise an exception

----------
label : str or None
A short label explaining to the user what this input is for.
value : int/float or None
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure where our previous converation went:

@jrhone it says int/float or None but we throw an error if they pass None I think
@arraydude That's something tricky because we could call the function with no value which would be None but if the user passes None we need to raise an exception

If we call the function without passing in a value it gets set to NoValue, not None, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right , i'm using that to check when the user specifies None to raise the exception.

@arraydude arraydude requested a review from tvst October 17, 2019 20:05
Copy link
Contributor

@tvst tvst left a comment

Choose a reason for hiding this comment

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

Looks great!!

I updated the CSS in the PR a bit to better match our theme: https://github.com/streamlit/streamlit/pull/416/files/a95c43b827cec72929fb43c883f9dc4905a79863..0f952fc1a8638d8b9a9f8109998b2cf6f3608d8b

One more thing, though: when I double-click the + or - button the "Value" text in the st.write below it gets selected for some reason. Any idea what's up there?

I mean this:
image

@arraydude arraydude requested a review from tvst October 21, 2019 17:00
Copy link
Contributor

@tvst tvst left a comment

Choose a reason for hiding this comment

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

Approved, but please address comments first.

</span>
<span
</button>
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a requirement for this PR, just an idea: why not use a BaseWeb Button here?

This way the button's "focus" and "hover" UX state would better match the UX we already have for other BaseWeb Buttons.

Although we'd have to update this button's theme, since our BaseWeb buttons look different from these. (White instead of gray, etc)

If this is too much work, no need to do it. But please at least copy the focus state from our BaseWeb widgets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the focus to get the same style as the hover, i changed the span to button due to the doble click select problem, the problem is if we use the BaseWeb Buttons, we are gonna need to overried the styles to match the feeling of the input as we are doing with the borders and background color, that's why i did not use the baseweb component

orbit-camera-controller "^4.0.0"
turntable-camera-controller "^3.0.0"

"@babel/code-frame@7.5.5", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5":
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh-oh yarn.lock has changed, so please run e2e tests and look at the screenshots for weirdness! See #479

@tvst
Copy link
Contributor

tvst commented Oct 22, 2019

Please add st.number_input to docs at docs/api.md

@arraydude
Copy link
Contributor Author

@tvst After checking the snapshots and added the needed documentation i will merge this PR

@arraydude arraydude merged commit 6098715 into streamlit:develop Oct 22, 2019
@arraydude arraydude deleted the feature/input-number branch October 22, 2019 17:07
@@ -0,0 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you yarn add from the project root instead of from 'frontend`?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting on #501, it was a mistake

tconkling added a commit to tconkling/streamlit that referenced this pull request Oct 23, 2019
* develop:
  Update Pipfile (streamlit#505)
  Release 0.49.0 (streamlit#509)
  Removing package json (streamlit#501)
  Feature/input number (streamlit#416)
tconkling added a commit to tconkling/streamlit that referenced this pull request Oct 29, 2019
* develop:
  Use custom context manager for temporary file in cli.py (streamlit#489)
  Update pull_request_template.md
  Update pull_request_template.md
  Handle lack of trailing slash (streamlit#528)
  Set auto_envvar_prefix to STREAMLIT (streamlit#477)
  Strip slashes in path components (streamlit#523)
  Create doc_improvement.md
  ESlint: allow @ts-ignore (streamlit#499)
  Update Pipfile (streamlit#505)
  Release 0.49.0 (streamlit#509)
  Removing package json (streamlit#501)
  Feature/input number (streamlit#416)
  ESLint warnings are fatal in Circle (streamlit#492)
  Doc updates (streamlit#286)
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.

3 participants