reflex icon indicating copy to clipboard operation
reflex copied to clipboard

FEATURE: added a datepicker module(#237)

Open muddi900 opened this issue 3 years ago β€’ 5 comments

Adds #237

Right now it only had the value prop, but I will add more as per comments.

muddi900 avatar Jan 10 '23 09:01 muddi900

Thanks for taking this on! A couple things the library seems to be react-datepicker does your code work locally? You will also need to add this library to our package.json

As for props and events -In addition to onChange we should support onSelect

More props can be these but snake case: closeOnScroll, dateFormat, startDate, endDate, minDate, maxDate, isClearable, placeholderText, showWeekNumbers, shouldCloseOnSelect

Alek99 avatar Jan 10 '23 20:01 Alek99

I have added the new props. However, should the date values be of datetime type? Or the framework handle it on its end.

I ahve not tested locally. I am working in a Codespace. The tests are running fine.

muddi900 avatar Jan 11 '23 08:01 muddi900

Looking good thanks for the changes, can you add comment and doc strings like our other components also can you text to see if it runs locally. https://github.com/pynecone-io/pynecone/blob/main/pynecone/components/datadisplay/datatable.py

Alek99 avatar Jan 12 '23 05:01 Alek99

I have added the docstring.

I am trying to test locally but I getting a ReferenceError: date_picker_state is not defined. I am following the wrapping docs quite literally. Do I need to define the state separately in the components?

here is my code.

class DatePickerState(pc.State):
    date = "1/1/2001"


def index():
    return pc.center(
        pc.vstack(
            pc.heading(DatePickerState.date),
            date_picker(on_change=DatePickerState.set_date),
            pc.box("Get started by editing ",
                   pc.code(filename, font_size="1em")),
            pc.link(
                "Check out our docs!",
                href=docs_url,
                border="0.1em solid",
                padding="0.5em",
                border_radius="0.5em",
                _hover={
                    "color": "rgb(107,99,246)",
                },
            ),
            spacing="1.5em",
            font_size="2em",
        ),
        padding_top="10%",
    )


# Add state and page to the app.
app = pc.App(state=State)
app.add_page(index)
app.compile()

muddi900 avatar Jan 18 '23 06:01 muddi900

It looks like you're passing the wrong State class to your app.

You probably want to do

app = pc.App(state=DatePickerState)

Or if you meant to use substates, you need to make sure your new class subclasses your base state rather than pc.State:

class State(pc.State):
    """"Base State"""

class DatePickerState(State):
    date = "1/1/2001"

app = pc.App(state=State)

picklelo avatar Jan 18 '23 07:01 picklelo

Going to close this pr seems inactive.

Alek99 avatar Jan 24 '23 02:01 Alek99