Skip to content

Commit 5ddf827

Browse files
authored
fix(ui): add the MdSaveBar component (#1233)
The save bar of a form that has unsaved changes was hand-built in SettingsView with its own style rule and a bottom clearance written inline. MdSaveBar is the sticky bar with the clearance from the bottom bar and the safe area as a class. No view uses it yet. Signed-off-by: TheMeinerLP <github@themeinerlp.dev>
1 parent f5637bc commit 5ddf827

6 files changed

Lines changed: 123 additions & 0 deletions

File tree

‎docs/gitbook/references/plugins/dashboard-anchors.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ A `stable` name is part of the contract. It is added in a minor release, and it
138138
| `md-page` | experimental | `src/components/md/MdPage.vue` | none | none | none |
139139
| `md-page-header` | experimental | `src/components/md/MdPageHeader.vue` | none | none | none |
140140
| `md-radio` | experimental | `src/components/md/MdRadio.vue` | none | none | none |
141+
| `md-save-bar` | experimental | `src/components/md/MdSaveBar.vue` | none | none | none |
141142
| `md-section` | experimental | `src/components/md/MdSection.vue` | none | none | none |
142143
| `md-select` | experimental | `src/components/md/MdSelect.vue` | none | none | none |
143144
| `md-select-renderer` (no element of its own) | stable | `src/components/renderers/MdSelectRenderer.vue` | none | none | none |

‎reposilite-frontend/DESIGN.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,17 @@ A button that opens a menu of actions on what it names, such as the actions of o
10741074
- Do: keep the destructive item last, after a separator, and mark it with `error`.
10751075
- Don't: use `!` modifiers on an item. They override the focus ring.
10761076

1077+
### MdSaveBar
1078+
1079+
The bar of a form with unsaved changes. It sticks to the bottom of its scroll container and, below the `medium` window class, stays above the bottom bar and the safe area.
1080+
1081+
- Props: none.
1082+
- Slots: `default` (the count of changes and the save and discard buttons).
1083+
- Events: none.
1084+
- Anchor: `md-save-bar`.
1085+
- Do: set the gap above the bar with a class on it, such as `mt-6`.
1086+
- Don't: offset the bar with an inline style or a `<style>` rule; the clearance is a class on the bar.
1087+
10771088
### MdSection
10781089

10791090
A titled group of content on a page. The title is a heading at level 2 for a section of a page, or level 3 for a section inside another one.

‎reposilite-frontend/src/anchors/registry.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@
10151015
"parts": [],
10161016
"states": []
10171017
},
1018+
{
1019+
"name": "md-save-bar",
1020+
"file": "src/components/md/MdSaveBar.vue",
1021+
"stability": "experimental",
1022+
"parts": [],
1023+
"states": []
1024+
},
10181025
{
10191026
"name": "md-section",
10201027
"file": "src/components/md/MdSection.vue",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2026 OneLiteFeather
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { describe, it, expect } from 'vitest'
18+
import { h } from 'vue'
19+
import { mount } from '@vue/test-utils'
20+
import MdSaveBar from './MdSaveBar.vue'
21+
22+
describe('MdSaveBar', () => {
23+
it('sticks to the bottom of its scroll container', () => {
24+
const wrapper = mount(MdSaveBar)
25+
26+
expect(wrapper.classes(), 'the bar must be sticky').toContain('sticky')
27+
expect(wrapper.classes(), 'the bar must sit at the bottom edge').toContain('bottom-0')
28+
})
29+
30+
it('keeps the bottom clearance of the bottom bar and the safe area as a class', () => {
31+
const wrapper = mount(MdSaveBar)
32+
33+
expect(
34+
wrapper.classes(),
35+
'below the medium window class the bar must clear the bottom bar and the safe area'
36+
).toContain('max-medium:bottom-[calc(var(--app-bottom-bar-height,0px)+env(safe-area-inset-bottom,0px))]')
37+
})
38+
39+
it('carries no inline style for the clearance', () => {
40+
const wrapper = mount(MdSaveBar)
41+
42+
expect(wrapper.attributes('style'), 'the clearance must be a class, not a style offset').toBeUndefined()
43+
})
44+
45+
it('renders the default slot as the content of the bar', () => {
46+
const wrapper = mount(MdSaveBar, {
47+
slots: { default: () => h('button', { 'data-test': 'save' }, 'Save') }
48+
})
49+
50+
expect(wrapper.find('[data-test="save"]').exists(), 'the slot content must sit inside the bar').toBe(true)
51+
})
52+
53+
it('carries the md-save-bar anchor on its root', () => {
54+
const wrapper = mount(MdSaveBar)
55+
56+
expect(wrapper.attributes('data-ingot-component')).toBe('md-save-bar')
57+
})
58+
59+
it('passes a caller class through to the bar', () => {
60+
const wrapper = mount(MdSaveBar, { attrs: { class: 'mt-6' } })
61+
62+
expect(wrapper.classes(), 'a caller class must land on the root').toContain('mt-6')
63+
})
64+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
- Copyright (c) 2026 OneLiteFeather
3+
-
4+
- Licensed under the Apache License, Version 2.0 (the "License");
5+
- you may not use this file except in compliance with the License.
6+
- You may obtain a copy of the License at
7+
-
8+
- http://www.apache.org/licenses/LICENSE-2.0
9+
-
10+
- Unless required by applicable law or agreed to in writing, software
11+
- distributed under the License is distributed on an "AS IS" BASIS,
12+
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
- See the License for the specific language governing permissions and
14+
- limitations under the License.
15+
-->
16+
17+
<script setup lang="ts">
18+
/*
19+
* Material Design 3 save bar: the bar of a form that has unsaved changes. It sticks to the bottom of its
20+
* scroll container and, below the medium window class, stays above the bottom bar and the safe area. The
21+
* content, such as the count of changes and the save and discard buttons, is the caller's slot.
22+
*/
23+
defineSlots<{
24+
default?(): unknown
25+
}>()
26+
</script>
27+
28+
<template>
29+
<div
30+
class="sticky bottom-0 z-md-sticky max-medium:bottom-[calc(var(--app-bottom-bar-height,0px)+env(safe-area-inset-bottom,0px))]"
31+
data-ingot-component="md-save-bar"
32+
>
33+
<slot />
34+
</div>
35+
</template>

‎reposilite-frontend/src/style-gate/baseline/arbitrary-value.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@
169169
"match": "transition-[width]",
170170
"count": 1
171171
},
172+
{
173+
"file": "src/components/md/MdSaveBar.vue",
174+
"match": "max-medium:bottom-[calc(var(--app-bottom-bar-height,0px)+env(safe-area-inset-bottom,0px))]",
175+
"count": 1
176+
},
172177
{
173178
"file": "src/components/md/MdSnackbar.vue",
174179
"match": "[&>svg]:size-6",

0 commit comments

Comments
 (0)