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

fix(VsConfirm): change confirm buttons style #340

Merged
merged 1 commit into from
Feb 21, 2025
Merged
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
20 changes: 20 additions & 0 deletions packages/vlossom/src/components/vs-confirmation/VsConfirm.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.vs-confirm {
display: flex;
height: 100%;

.vs-confirm-wrap {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding-top: 2.4rem;
}

.vs-confirm-buttons {
margin-top: 3.6rem;
display: flex;
align-items: center;
justify-content: center;
}
}
38 changes: 13 additions & 25 deletions packages/vlossom/src/components/vs-confirmation/VsConfirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
<div class="vs-confirm-wrap">
<slot />
<div class="vs-confirm-buttons">
<vs-button ref="okRef" :style-set="plainStyleSet?.okButton" @click="ok" primary>{{ okText }}</vs-button>
<vs-button :style-set="plainStyleSet?.cancelButton" @click="cancel">{{ cancelText }}</vs-button>
<vs-button ref="okRef" :style-set="getButtonStyleSet(plainStyleSet?.okButton)" @click="ok" primary>
{{ okText }}
</vs-button>
<vs-button :style-set="getButtonStyleSet(plainStyleSet?.cancelButton)" @click="cancel">
{{ cancelText }}
</vs-button>
</div>
</div>
</div>
Expand All @@ -18,6 +22,7 @@ import { useStyleSet } from '@/composables';
import VsButton from '@/components/vs-button/VsButton.vue';

import type { VsConfirmStyleSet } from './types';
import type { VsButtonStyleSet } from '@/components/vs-button/types';

const name = VsComponent.VsConfirm;
export default defineComponent({
Expand All @@ -32,6 +37,10 @@ export default defineComponent({
const { styleSet } = toRefs(props);
const { plainStyleSet } = useStyleSet<VsConfirmStyleSet>(name, styleSet);

function getButtonStyleSet(buttonStyleSet: VsButtonStyleSet = {}) {
return { width: '12rem', ...buttonStyleSet };
}

function ok() {
const id = store.overlay.getLastOverlayId();
store.overlay.run<boolean>(id, VS_CONFIRM_OK);
Expand All @@ -42,30 +51,9 @@ export default defineComponent({
store.overlay.run<boolean>(id, VS_CONFIRM_CANCEL);
}

return { plainStyleSet, ok, cancel };
return { plainStyleSet, getButtonStyleSet, ok, cancel };
},
});
</script>

<style lang="scss" scoped>
.vs-confirm {
display: flex;
height: 100%;

.vs-confirm-wrap {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding-top: 1.6rem;
}

.vs-confirm-buttons {
margin-top: 5rem;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>
<style lang="scss" src="./VsConfirm.scss" />
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useContentRenderer } from '@/composables';
export const confirmPlugin: ConfirmPlugin = {
open: (content: string | Component, confirmOptions: ConfirmOptions = {}): Promise<boolean> => {
return new Promise((resolve) => {
const { okText, cancelText, size = 'xs', callbacks = {}, styleSet, props } = confirmOptions;
const { okText, cancelText, callbacks = {}, styleSet, props } = confirmOptions;
const { getRenderedContent } = useContentRenderer();
const modalId = modalPlugin.open({
...confirmOptions,
Expand All @@ -21,7 +21,6 @@ export const confirmPlugin: ConfirmPlugin = {
},
},
),
size,
callbacks: {
...callbacks,
[VS_CONFIRM_OK]: () => {
Expand Down