-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add responsive props to radix components #3583
Conversation
* order type annotations in pyi_generator * run pyi_generator
* classvars should not be backend vars * cleanup RESERVED_BACKEND_VAR_NAMES
* order type annotations in pyi_generator * run pyi_generator
* do not validate non-cached var deps * further improve Exceptions for misconfigured var deps
* order type annotations in pyi_generator * run pyi_generator
One behavior we're missing is using list operator to define responsive props for radix components. Is this something we're interested in having? @picklelo |
In the interest of easing merge requests, we can merge this and add list syntax radix props in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this actually work if the Breakpoints
is inside a Var
? for example in state:
class S(rx.State):
bps: rx.breakpoints.__self__ = rx.breakpoints(
initial="1",
xs="2",
sm="2",
md="3",
lg="4",
xl="5",
)
def index():
return rx.vstack(
"hello world",
"foo",
"bar",
"baz",
spacing=S.bps,
)
when i try it like that it kind of blows up
File "/Users/masen/code/reflex-dev/reflex/reflex/components/component.py", line 811, in create
return cls(children=children, **props)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masen/code/reflex-dev/reflex/reflex/components/component.py", line 444, in __init__
and not types._issubclass(passed_type, expected_type, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masen/code/reflex-dev/reflex/reflex/utils/types.py", line 392, in _issubclass
return _breakpoints_satisfies_typing(cls_check, instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masen/code/reflex-dev/reflex/reflex/utils/types.py", line 352, in _breakpoints_satisfies_typing
return any(
^^^^
File "/Users/masen/code/reflex-dev/reflex/reflex/utils/types.py", line 353, in <genexpr>
_breakpoints_satisfies_typing(type_to_check, instance)
File "/Users/masen/code/reflex-dev/reflex/reflex/utils/types.py", line 346, in _breakpoints_satisfies_typing
for value in instance.values():
^^^^^^^^^^^^^^^
File "/Users/masen/code/reflex-dev/reflex/reflex/vars.py", line 819, in __getattr__
raise VarAttributeError(
reflex.utils.exceptions.VarAttributeError: The State var `state__s.bps` has no attribute 'values' or may have been annotated wrongly.
i think, at least initially, we need to ensure that the Breakpoints
is handled at compile time (i.e. cannot be in a dynamic frontend Var), or we need to ignore the type checking if the Breakpoints
is in a Var
.
I tend to lean toward the former, because we definitely cannot support Var[Breakpoint]
for the CSS props as it's written now, so we shouldn't introduce an inconsistency between the two.
My other question is about Var
within an rx.breakpoints
dict, the type checking seems to get bungled up on this, but since the style props have no type checking, it actually does seem to work if the value comes from a Var
Good catch! I think the issue I ran through was doing a union simply broke pydantic and I wasn't sure how, so that was the only thing that typechecked fine. I will see if it can be fixed more towards the right way. |
It actually seems fine, we can handle breakpoints in var after fixing an issue with typing. But we do lose validation when used in a state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will take this for now, but i have a followup PR to clean up some of the generated .pyi files coming
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [reflex](https://reflex.dev) ([source](https://togithub.com/reflex-dev/reflex)) | project.dependencies | patch | `==0.5.5` -> `==0.5.6` | --- ### Release Notes <details> <summary>reflex-dev/reflex (reflex)</summary> ### [`v0.5.6`](https://togithub.com/reflex-dev/reflex/releases/tag/v0.5.6) [Compare Source](https://togithub.com/reflex-dev/reflex/compare/v0.5.5...v0.5.6) #### New Features ##### `rx.clipboard` Handle global and component-scoped `on_paste` with multi-type data - Add Clipboard component for handling global on_paste event by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3513](https://togithub.com/reflex-dev/reflex/pull/3513) ##### `rx.breakpoints` - Set breakpoints by name - introduce customizable breakpoints by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3568](https://togithub.com/reflex-dev/reflex/pull/3568) - add responsive props to radix components by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3583](https://togithub.com/reflex-dev/reflex/pull/3583) ##### Computed Backend Vars - add computed backend vars by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3573](https://togithub.com/reflex-dev/reflex/pull/3573) - improve backend var determination by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3587](https://togithub.com/reflex-dev/reflex/pull/3587) #### Improvements - \[REF-3056]Config knob for redis StateManager expiration times by [@​ElijahAhianyo](https://togithub.com/ElijahAhianyo) in [https://github.com/reflex-dev/reflex/pull/3523](https://togithub.com/reflex-dev/reflex/pull/3523) - \[Perf] Ensure rx.match gets memoized to avoid excessive re-rendering by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3552](https://togithub.com/reflex-dev/reflex/pull/3552) - bare sqlalchemy session + tests by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3522](https://togithub.com/reflex-dev/reflex/pull/3522) - Remove chakra from codeblock by [@​abulvenz](https://togithub.com/abulvenz) in [https://github.com/reflex-dev/reflex/pull/3570](https://togithub.com/reflex-dev/reflex/pull/3570) - add compilation timestamp in log by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3563](https://togithub.com/reflex-dev/reflex/pull/3563) - \[REF-3148] add props for tabs by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3560](https://togithub.com/reflex-dev/reflex/pull/3560) - show the value causing problem in deprecation warning by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3558](https://togithub.com/reflex-dev/reflex/pull/3558) - Better support for Github Codespaces - Add a link to backend in connection error by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3044](https://togithub.com/reflex-dev/reflex/pull/3044) - Better hot reload times on Windows with python 3.12 and uvicorn > 0.20 - \[REF-3164] Hack to fix Windows hot reload + Uvicorn upgrade by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3584](https://togithub.com/reflex-dev/reflex/pull/3584) - `rx.theme` appearance is reset in dev mode - \[REF-2588]Clear color mode local storage for dev mode by [@​ElijahAhianyo](https://togithub.com/ElijahAhianyo) in [https://github.com/reflex-dev/reflex/pull/3548](https://togithub.com/reflex-dev/reflex/pull/3548) #### Bug Fixes - Fix radix radio cards component by [@​emmakodes](https://togithub.com/emmakodes) in [https://github.com/reflex-dev/reflex/pull/3545](https://togithub.com/reflex-dev/reflex/pull/3545) - fix small typing issue by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3562](https://togithub.com/reflex-dev/reflex/pull/3562) - \[REF-3185]\[REF-3180]Dont escape backticks in JS string interpolation by [@​ElijahAhianyo](https://togithub.com/ElijahAhianyo) in [https://github.com/reflex-dev/reflex/pull/3566](https://togithub.com/reflex-dev/reflex/pull/3566) - classvars should not be backend vars by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3578](https://togithub.com/reflex-dev/reflex/pull/3578) - ComponentState and State mixins now work with backend vars - copy backend vars from mixins by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3580](https://togithub.com/reflex-dev/reflex/pull/3580) - fix var dependency over properties by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3588](https://togithub.com/reflex-dev/reflex/pull/3588) - \[REF-3157] Avoid SQLModel metaclass conflict ([#​3610](https://togithub.com/reflex-dev/reflex/issues/3610)) - \[REF-3220] Fix rx.cancel_upload EventSpec ([#​3608](https://togithub.com/reflex-dev/reflex/issues/3608)) - do not get_config in global scope ([#​3597](https://togithub.com/reflex-dev/reflex/issues/3597)) #### Other Changes - Validate ComputedVar dependencies, add tests by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3527](https://togithub.com/reflex-dev/reflex/pull/3527) - do not validate non-cached var deps by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3576](https://togithub.com/reflex-dev/reflex/pull/3576) - Radio group fix deprecation warning for creating vars with strings by [@​ElijahAhianyo](https://togithub.com/ElijahAhianyo) in [https://github.com/reflex-dev/reflex/pull/3567](https://togithub.com/reflex-dev/reflex/pull/3567) - update dependencies pinning by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3556](https://togithub.com/reflex-dev/reflex/pull/3556) - fix formatting by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3574](https://togithub.com/reflex-dev/reflex/pull/3574) - order type annotations in pyi_generator by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3585](https://togithub.com/reflex-dev/reflex/pull/3585) - Deprecate cached var by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3582](https://togithub.com/reflex-dev/reflex/pull/3582) - Change Strategy Prop to Literal by [@​Alek99](https://togithub.com/Alek99) in [https://github.com/reflex-dev/reflex/pull/3575](https://togithub.com/reflex-dev/reflex/pull/3575) - pyi_generator cleanup: ruff, remove fully qualified reflex. names by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3591](https://togithub.com/reflex-dev/reflex/pull/3591) - cleanup unused check by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3590](https://togithub.com/reflex-dev/reflex/pull/3590) - split lifespan and middleware logic in separate mixin files by [@​Lendemor](https://togithub.com/Lendemor) in [https://github.com/reflex-dev/reflex/pull/3557](https://togithub.com/reflex-dev/reflex/pull/3557) - Update links to /docs/library/dynamic-rendering/foreach/ ([#​3609](https://togithub.com/reflex-dev/reflex/issues/3609)) #### New Contributors ##### Welcome Khaleel to the Core Team - [@​adhami3310](https://togithub.com/adhami3310) made their first contribution in [https://github.com/reflex-dev/reflex/pull/3568](https://togithub.com/reflex-dev/reflex/pull/3568) **Full Changelog**: reflex-dev/reflex@v0.5.5...v0.5.6 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission: