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(codex-ui): popup and confirm implementation #254

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

elizachi
Copy link
Contributor

@elizachi elizachi commented Jul 6, 2024

Added popup and confirm components

image

  • Popup can be called by showPopup() function
  • A showPopup() function can be added to any component, for example with @ click
  • You can also embed any component in the popup itself using showPopup() with component and props parameters
  • As an example, a new confirm component was embeded into the popup
  • The window can be closed using the optional close button
  • When you click on the confirm buttons, you can trigger any events, passing them to the confirm as on-close-activate and on-confirm-activate

codex-ui/dev/pages/components/Popup.vue Outdated Show resolved Hide resolved
codex-ui/dev/pages/components/Popup.vue Outdated Show resolved Hide resolved
codex-ui/dev/pages/components/Popup.vue Outdated Show resolved Hide resolved
codex-ui/dev/pages/components/Popup.vue Outdated Show resolved Hide resolved
codex-ui/src/vue/components/popup/Confirm.vue Outdated Show resolved Hide resolved
<style module>

.popup {
z-index: var(--z-popover);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets a separate variable in z-axis.pcss --z-popup which will be cal(var(--z-popover) + 1)

codex-ui/src/vue/components/popup/Confirm.vue Outdated Show resolved Hide resolved
/**
* Text that will be displayed in the middle part of the confirm container
*/
body: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: string;
text: string;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also create a useConfirm() composable? It will be a preset using Popup + Confirm. It will simplify end usage.

Also, it is useful if "confirm" will return a promise.

Example:

const { confirm } = useConfirm()

async function deleteNote() {
  try {
    await confirm('Are you sure')?
    
    service.deleteNote()
  } catch(e){}
}

});

/**
* Check every 100 ms to see if the user has pressed the button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have callback in confirm props, so interval is not needed

Comment on lines 60 to 61
onCancel,
onConfirm,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant methods, they should be passed to the showPopup

import PageHeader from '../../components/PageHeader.vue';
import { Button, useConfirm } from '../../../src/vue';

const { confirm } = useConfirm();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create another page for Confirm examle. And Popup page will show anything else inside (for example just a stub text like "Popup can include any component") to demonstrate its nature

/**
* Check if the user has pressed the confirm or close button
*/
return new Promise<boolean>((resolve) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets get rid of result ref, you can wrap showPopup with this promise:

return new Promise<boolean>((resolve) => {
  showPopup( ... )
})

box-shadow: inset 0 0 0 var(--delimiter-height) var(--base--border);
}

&__icon {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The close button is displayed lower than it should be.

image image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, please add hover to it. (Making icon and border color of --base--text)

Copy link
Contributor Author

@elizachi elizachi Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The close button is displayed lower than it should be.

image image

The exact same sized icon is on the icon page - all indents are respected
There is a similar case in tabbar component, I think this is a problem with icons in general

Comment on lines 72 to 78
onMounted(() => {
document.addEventListener('keydown', closeOnEsc);
});

onUnmounted(() => {
document.removeEventListener('keydown', closeOnEsc);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to usePopup please

@@ -16,23 +16,15 @@

<script setup lang="ts">
import PageHeader from '../../components/PageHeader.vue';
import { Button, useConfirm } from '../../../src/vue';
import { StubText, Button, usePopup } from '../../../src/vue';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stub Text should not be a part of the design system. You can define it here

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

Successfully merging this pull request may close these issues.

4 participants