Skip to content
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

feat: update sys-form to use display: grid by default #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/sys-form-error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
border: 1px solid var(--color-light-form-input-border);
color: var(--color-light-form-input-background);
display: block;
grid-column: 1 / -1;
padding: 0.5rem;
}
</style>
8 changes: 0 additions & 8 deletions src/components/sys-form-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<validation-provider
ref="provider"
v-slot="{ errors, required, ariaInput, ariaMsg }"
:class="$style.formgroup"
:disabled="disabled"
:name="id"
:rules="rules"
Expand Down Expand Up @@ -166,10 +165,3 @@
}
}
</script>

<style module>
.formgroup {
display: block;
margin: 0.6rem 0;
}
</style>
5 changes: 0 additions & 5 deletions src/components/sys-form-markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@
</script>

<style module>
.formgroup {
display: block;
margin: 0.6rem 0;
}

.label {
display: flex;
flex-wrap: nowrap;
Expand Down
9 changes: 1 addition & 8 deletions src/components/sys-form-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

<template>
<div :class="$style.formgroup">
<div>
<sys-label :for="id">
{{ label }}
</sys-label>
Expand Down Expand Up @@ -102,10 +102,3 @@
}
}
</script>

<style module>
.formgroup {
display: block;
margin: 0.6rem 0;
}
</style>
8 changes: 0 additions & 8 deletions src/components/sys-form-textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<validation-provider
ref="provider"
v-slot="{ errors, required, ariaInput, ariaMsg }"
:class="$style.formgroup"
:disabled="disabled"
:name="id"
:rules="rules"
Expand Down Expand Up @@ -160,10 +159,3 @@
}
}
</script>

<style module>
.formgroup {
display: block;
margin: 0.6rem 0;
}
</style>
17 changes: 17 additions & 0 deletions src/components/sys-form.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ please take a look at the example storybooks.

<Props of={SysForm} />

## Styling

By default, the form element is `display: grid`. This allows you to build some
fancy multi line forms while avoiding a bunch of the messy margin properties.

For this to work, if you are putting inputs next to each other, you need to
explicit set the grid columns like so:

```css
form {
grid-template-columns: repeat(3, 1fr);
}
```

If you do not do this, the bottom action buttons will not span to the end and
look off.

### Normal

This is how a basic form would look.
Expand Down
10 changes: 8 additions & 2 deletions src/components/sys-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@

<style module>
.form {
display: block;
align-content: stretch;
align-items: stretch;
display: grid;
grid-gap: 0.4rem 1rem;
grid-template-columns: 1fr;
justify-content: stretch;
margin: 0;
min-width: calc(320px - 2rem);
padding: 0;
Expand All @@ -172,7 +177,8 @@
align-items: center;
display: flex;
flex-wrap: wrap;
grid-column: 1 / -1;
justify-content: flex-end;
margin: -0.4rem 0 0;
margin: -0.5rem 0;
}
</style>