Skip to content

Commit

Permalink
K4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Dec 8, 2023
1 parent 694d1a2 commit d623566
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion index.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
p{margin-bottom:var(--spacing-2)}.k-button-field-button{display:block;width:100%;text-align:left}
[dir=ltr] .k-button-field button{text-align:left}[dir=rtl] .k-button-field button{text-align:right}.k-button-field button{width:100%;justify-content:start}
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Kirby\Cms\App as Kirby;

Kirby::plugin('moritzebeling/kirby-panel-button', [

'fields' => [
'button' => [
'props' => [
Expand Down Expand Up @@ -74,4 +73,4 @@
// ]
// ],

]);
]);
130 changes: 68 additions & 62 deletions src/ButtonField.vue
Original file line number Diff line number Diff line change
@@ -1,73 +1,79 @@
<template>
<k-field class="k-button-field" :label="label" :help="help">
<k-field class="k-button-field" :label="label" :help="help">
<div class="k-button-field-button-wrapper">
<k-button
v-if="!isLoading"
:theme="theme"
:icon="icon"
variant="filled"
@click="onClick"
>
{{ text }}
</k-button>

<div class="k-button-field-button-wrapper">
<k-button
v-if="isLoading && !hasError"
:disabled="true"
icon="dots"
theme="info"
variant="filled"
data-disabled="true"
>
Please wait
</k-button>

<button v-if="!isLoading" type="button" class="k-button-field-button k-button k-box" :data-theme="theme" @click="onClick">
<k-icon :type="icon" class="k-button-icon" />
<span class="k-button-text">{{ text }}</span>
</button>

<div v-if="isLoading && !hasError" type="button" class="k-button-field-button k-button k-button-disabled k-box" data-disabled="true">
<k-icon type="dots" class="k-button-icon" />
<span class="k-button-text">Please wait</span>
</div>

<div v-if="hasError" type="button" class="k-button-field-button k-button k-button-disabled k-box" data-disabled="true" data-theme="negative">
<k-icon type="alert" class="k-button-icon" />
<span class="k-button-text">Error</span>
</div>

</div>

</k-field>
<k-button
v-if="hasError"
:disabled="true"
icon="alert"
theme="negative"
variant="filled"
@click="onClick"
>
Error
</k-button>
</div>
</k-field>
</template>

<script>
import {openUrlInNewTab, triggerWebhook} from "./methods";
import { openUrlInNewTab, triggerWebhook } from "./methods";
export default {
props: {
label: String,
text: String,
url: String,
theme: String,
icon: String,
open: Boolean,
reload: Boolean,
help: String,
isLoading: true,
hasError: false
},
methods: {
async onClick(){
if( this.open === true ){
/*
open url in new tab
*/
openUrlInNewTab( this );
} else {
/*
trigger webhook
*/
triggerWebhook( this );
}
}
}
export default {
props: {
label: String,
text: String,
url: String,
theme: String,
icon: String,
open: Boolean,
reload: Boolean,
help: String,
isLoading: true,
hasError: false
},
methods: {
async onClick() {
if (this.open === true) {
/*
open url in new tab
*/
openUrlInNewTab(this);
} else {
/*
trigger webhook
*/
triggerWebhook(this);
}
}
}
}
</script>

<style>
p {
margin-bottom: var(--spacing-2);
}
.k-button-field-button {
display: block;
width: 100%;
text-align: left;
}
</style>
.k-button-field button {
width: 100%;
text-align: start;
justify-content: start;
}
</style>
7 changes: 1 addition & 6 deletions src/_ButtonSection.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<template>
<k-field class="k-button-section" :label="headline">
<div class="k-box" :data-theme="theme">

<p v-if="text">{{text}}</p>

<k-button :icon="icon">{{ button }}</k-button>

</div>
</k-field>
</template>
Expand Down Expand Up @@ -36,9 +33,7 @@
</script>

<style>
p {
margin-bottom: var(--spacing-2);
}
</style>
</style>

0 comments on commit d623566

Please sign in to comment.