-
-
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.
Merge pull request #34 from SkwalExe/winmb
add winmb page
- Loading branch information
Showing
5 changed files
with
131 additions
and
17 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 |
---|---|---|
@@ -1,8 +1,22 @@ | ||
<template> | ||
<div | ||
class="text-center text-white inline-flex bg-gradient-to-br from-accent/80 to-violet-500/80 border-white/40 border-[2px] hover:opacity-100 opacity-90 transition duration-300 rounded-md px-7 py-4 cursor-pointer hover:shadow-lg hover:shadow-accent/80"> | ||
:class="`fancy-button-${type} text-center text-white inline-flex bg-gradient-to-br border-white/40 border-[2px] hover:opacity-100 opacity-90 transition duration-300 rounded-md px-7 py-4 cursor-pointer`"> | ||
<p class="w-full"> | ||
<slot /> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const { type } = defineProps({ | ||
type: { | ||
type: String, | ||
requird: true, | ||
default: 'blue' | ||
} | ||
}) | ||
if (!['red', 'blue', 'yellow', 'green'].includes(type)) throw new Error('Invalid fancy button type') | ||
</script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,64 @@ | ||
<template> | ||
<BoxFancy> | ||
<h1>🪟 WinMB.js</h1> | ||
<p> | ||
WinMB.js is a library that enables developers to create Windows-style message boxes directly on their | ||
websites. This tool provides a way to integrate familiar dialog boxes by mimicking the native Windows | ||
interface. You can find this library on GitHub, as well as its documentation. | ||
</p> | ||
<div class="mt-5"> | ||
<Lnk :new-tab="true" href="https://github.com/Skwalexe/WinMB.js"> | ||
<ButtonFancy class="w-full">Github & Documentation</ButtonFancy> | ||
</Lnk> | ||
</div> | ||
</BoxFancy> | ||
<BoxFancy> | ||
<h1>🎥 Demonstration</h1> | ||
<div class="justify-center inline-flex gap-4 flex-wrap"> | ||
<ButtonFancy type="red" @click="demo('error')">Error message</ButtonFancy> | ||
<ButtonFancy @click="demo('info')">Information box</ButtonFancy> | ||
<ButtonFancy type="yellow" @click="demo('warning')">Warning box</ButtonFancy> | ||
</div> | ||
<div class="mt-3"> | ||
<label for="randomize-position"> | ||
<input id="randomize-position" v-model="randomPosition" class="accent-teal-500" type="checkbox" /> | ||
<span>Randomize position</span> | ||
</label> | ||
</div> | ||
<hr /> | ||
<h2>↩️ Return value</h2> | ||
<input v-model="returnValue" type="text" placeholder="Return value" disabled /> | ||
</BoxFancy> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import WinMB from '@skwalexe/winmb' | ||
import Error from '~/error.vue' | ||
const returnValue: Ref<string> = ref('') | ||
const randomPosition: Ref<boolean> = ref(false) | ||
const wmb: Ref<null | WinMB> = ref(null) | ||
const messageBoxes: {[key: string]: string[]} = { | ||
"error": ['CRITICAL ERROR', 'This is an error message!'], | ||
"info": ['Information', 'This is a notice!'], | ||
"warning": ['ATTENTION', 'This is a warning!!!!'] | ||
} | ||
onMounted(() => { | ||
wmb.value = new WinMB('https://cdn.jsdelivr.net/gh/SkwalExe/WinMB.js@0.1.2/src/assets/') | ||
}) | ||
const demo = async (boxType: string): Promise<void> => { | ||
if (wmb.value === null) throw new Error('wmb is not loaded yet (wmb null)') | ||
if (!['error', 'info', 'warning'].includes(boxType)) throw new Error('boxType must be in [error, info, warning]') | ||
returnValue.value = (await wmb.value.show( | ||
messageBoxes[boxType][0], // title | ||
messageBoxes[boxType][1], // message | ||
boxType, | ||
[{text: 'Hello'}, {text: 'World'}], | ||
randomPosition.value ? 'random' : 'default' | ||
)).toString() | ||
} | ||
</script> |