-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added plugin based context registration and readme
- Loading branch information
Showing
19 changed files
with
383 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { defineComponent } from 'vue' | ||
import { ModalisProvider, ModalisView } from '../src' | ||
import { Page } from './Page' | ||
|
||
export const AppWithUse = defineComponent({ | ||
setup() { | ||
return () => ( | ||
<div> | ||
<h1>Application with ModalisView and vue plugin</h1> | ||
<Page /> | ||
<ModalisView /> | ||
</div> | ||
) | ||
}, | ||
}) | ||
export const AppWithProvider = defineComponent({ | ||
setup() { | ||
return () => ( | ||
<div> | ||
<h1>Application with ModalisProvider</h1> | ||
<ModalisProvider> | ||
<Page /> | ||
</ModalisProvider> | ||
</div> | ||
) | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.example-modal { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
.modal-container { | ||
display: flex; | ||
flex-direction: column; | ||
width: 20rem; | ||
background-color: white; | ||
border-radius: 15px; | ||
-webkit-box-shadow: 4px 3px 15px -4px rgba(0, 0, 0, 0.75); | ||
-moz-box-shadow: 4px 3px 15px -4px rgba(0, 0, 0, 0.75); | ||
box-shadow: 4px 3px 15px -4px rgba(0, 0, 0, 0.75); | ||
.modal-title { | ||
display: block; | ||
text-align: center; | ||
padding: 1rem 3rem; | ||
} | ||
.modal-body { | ||
display: block; | ||
text-align: left; | ||
padding: 1rem 3rem; | ||
} | ||
.modal-footer { | ||
display: block; | ||
text-align: center; | ||
padding: 1rem 3rem; | ||
button { | ||
padding: 1rem; | ||
border: 1px solid black; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { defineComponent, defineProps, defineEmits } from 'vue' | ||
import { createModal, useModal } from '../src' | ||
import styles from './ExampleModalComponent.module.scss' | ||
export type ModalData = { | ||
title: string | ||
body: string | ||
} | ||
|
||
export type ReturnType = { | ||
num: number | ||
} | ||
|
||
export class ErrorOne extends Error {} | ||
export class ErrorTwo extends Error {} | ||
|
||
export const ExampleModal = defineComponent({ | ||
props: { | ||
title: String, | ||
body: String, | ||
}, | ||
emits: { | ||
return(data: ReturnType) { | ||
return true | ||
}, | ||
throw(error: unknown) { | ||
return true | ||
}, | ||
}, | ||
setup(props, { emit }) { | ||
const close = () => { | ||
emit('return', { num: 12 }) | ||
} | ||
const error = () => { | ||
emit('throw', new Error('Random error')) | ||
} | ||
const errorOne = () => { | ||
emit('throw', new ErrorOne('Random error')) | ||
} | ||
const errorTwo = () => { | ||
emit('throw', new ErrorTwo('Random error')) | ||
} | ||
return () => ( | ||
<div className={styles['example-modal']}> | ||
<div className={styles['modal-container']}> | ||
<div className={styles['modal-title']}>{props.title}</div> | ||
<div className={styles['modal-body']}>{props.body}</div> | ||
<div className={styles['modal-footer']}> | ||
<button onClick={close}>Close</button> | ||
<button onClick={errorOne}>Error 1</button> | ||
<button onClick={errorTwo}>Error 2</button> | ||
<button onClick={error}>Error unexpected</button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
}, | ||
}) | ||
|
||
const exampleModal = createModal<ModalData, ReturnType>({ | ||
component: ExampleModal, | ||
}) | ||
|
||
export const useExampleModal = () => useModal(exampleModal) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { defineComponent } from 'vue' | ||
import { useExampleModal, ErrorOne, ErrorTwo } from './ExampleModalComponent' | ||
|
||
export const Page = defineComponent({ | ||
setup() { | ||
const { showModal: showExampleModal } = useExampleModal() | ||
const showExample = async () => { | ||
try { | ||
const asd = await showExampleModal({ | ||
body: 'asd', | ||
title: 'kek', | ||
}) | ||
console.log(asd.num) | ||
} catch (error: unknown) { | ||
if (error instanceof ErrorOne) { | ||
console.log('ErrorOne occured') | ||
} else if (error instanceof ErrorTwo) { | ||
console.log('ErrorTwo occured') | ||
} else { | ||
console.log('An unexpected error occured') | ||
} | ||
} | ||
} | ||
return () => ( | ||
<div> | ||
<button onClick={showExample}>Show example modal</button> | ||
</div> | ||
) | ||
}, | ||
}) |
Oops, something went wrong.