Add password component (#519)

This commit is contained in:
Nikhil Rao 2023-02-12 09:57:42 -08:00 committed by GitHub
parent c203ad57a4
commit 8c8b2396fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from pynecone.compiler import utils as compiler_utils
from pynecone.components.component import Component, ComponentStyle
from pynecone.event import Event, EventHandler
from pynecone.middleware import HydrateMiddleware, Middleware
from pynecone.model import Model
from pynecone.route import DECORATED_ROUTES
from pynecone.state import DefaultState, Delta, State, StateManager, StateUpdate
@ -316,6 +317,10 @@ class App(Base):
print("Skipping compilation in non-dev mode.")
return
# Update models during hot reload.
if config.db_url is not None:
Model.create_all()
# Empty the .web pages directory
compiler.purge_web_pages_dir()

View File

@ -14,6 +14,7 @@ from .numberinput import (
NumberInputField,
NumberInputStepper,
)
from .password import Password
from .pininput import PinInput, PinInputField
from .radio import Radio, RadioGroup
from .rangeslider import (

View File

@ -0,0 +1,11 @@
"""A password input component."""
from pynecone.components.forms.input import Input
from pynecone.var import Var
class Password(Input):
"""A password input component."""
# The type of input.
type_: Var[str] = "password" # type: ignore

View File

@ -49,7 +49,6 @@ if TYPE_CHECKING:
from pynecone.components.component import ImportDict
from pynecone.config import Config
from pynecone.event import Event, EventHandler, EventSpec
from pynecone.model import Model
from pynecone.var import Var
# Shorthand for join.
@ -720,6 +719,9 @@ def setup_backend():
Specifically ensures backend database is updated when running --no-frontend.
"""
# Import here to avoid circular imports.
from pynecone.model import Model
config = get_config()
if config.db_url is not None:
Model.create_all()