Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Opt-in mechanism for CSS on form inputs and buttons #2415

Closed
simonw opened this issue Sep 3, 2024 · 6 comments
Closed

Opt-in mechanism for CSS on form inputs and buttons #2415

simonw opened this issue Sep 3, 2024 · 6 comments
Labels
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Sep 3, 2024

I think I need to introduce an opt-in mechanism to Datasette core classes, maybe a class of core - which can be used directly on the button or can be put on a wrapper element, such as a form.

Originally posted by @simonw in datasette/datasette-acl#24 (comment)

@simonw
Copy link
Owner Author

simonw commented Sep 3, 2024

Here's the problem this can help solve, found while attempting to integrate https://github.com/Choices-js/Choices into datasette-acl:

CleanShot 2024-09-03 at 07 23 33@2x

Those look weird because the Datasette default CSS targets form button[type="button"] with a bunch of styles that don't work with Choices.

@simonw
Copy link
Owner Author

simonw commented Sep 3, 2024

Here's the CSS causing the problem:

form input[type=text],
form input[type=search] {
border: 1px solid #ccc;
border-radius: 3px;
width: 60%;
padding: 9px 4px;
display: inline-block;
font-size: 1em;
font-family: Helvetica, sans-serif;
}
/* Stop Webkit from styling search boxes in an inconsistent way */
/* https://css-tricks.com/webkit-html5-search-inputs/ comments */
input[type=search] {
-webkit-appearance: textfield;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
display: none;
}
form input[type=submit], form button[type=button] {
font-weight: 400;
cursor: pointer;
text-align: center;
vertical-align: middle;
border-width: 1px;
border-style: solid;
padding: .5em 0.8em;
font-size: 0.9rem;
line-height: 1;
border-radius: .25rem;
}
form input[type=submit] {
color: #fff;
background: linear-gradient(180deg, #007bff 0%, #4E79C7 100%);
border-color: #007bff;
-webkit-appearance: button;
}
form button[type=button] {
color: #007bff;
background-color: #fff;
border-color: #007bff;
}

I'm going to change it so you need to add class="core" either to the inputs and buttons directly or to a containing element to get those styles.

This will be a frustrating change because it will break the display of buttons in a bunch of plugins, so best to get it done before 1.0!

@simonw
Copy link
Owner Author

simonw commented Sep 3, 2024

This is the kind of thing that breaks in Datasette core itself - will have to go through a bunch of these:

CleanShot 2024-09-03 at 08 15 26@2x

@simonw
Copy link
Owner Author

simonw commented Sep 3, 2024

Using <form class="core"> is a quick way to fix these.

@simonw
Copy link
Owner Author

simonw commented Sep 3, 2024

Need to update a whole bunch of plugins.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant