Skip to content

Commit

Permalink
1.1.0 - Added on Tab Change Event
Browse files Browse the repository at this point in the history
  • Loading branch information
poirazis committed Feb 19, 2023
1 parent 781b6af commit 252d713
Show file tree
Hide file tree
Showing 6 changed files with 418 additions and 264 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#033335",
"titleBar.activeBackground": "#04484A",
"titleBar.activeForeground": "#ECFDFE"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bb-component-SuperTabs",
"version": "1.0.1",
"version": "1.1.0",
"description": "A Tabs component for Budibase with Super Powers",
"author": "Michael Poirazi",
"license": "MIT",
Expand Down
16 changes: 16 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@
"label": "Emphasized Color",
"key": "emphasizedColor",
"dependsOn": "emphasized"
},
{
"section": true,
"name": "On Tab Change",
"settings": [
{
"type": "event",
"key": "onTabChange",
"context": [
{
"label": "Active Tab Name",
"key": "tabName"
}
]
}
]
}
]
}
Expand Down
15 changes: 12 additions & 3 deletions src/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export let compact = false
export let emphasized = false
export let emphasizedColor = "var(--primaryColor)"
export let onTabChange
const { styleable, builderStore, screenStore, componentStore } = getContext("sdk")
const component = getContext("component")
Expand All @@ -25,6 +26,7 @@
// Set Store initial State
let selectedTab = {
id : undefined,
name : "",
boundingBox: null,
}
const tabStore = writable(selectedTab)
Expand Down Expand Up @@ -84,13 +86,17 @@
}
}
}
function handleTabChange ( e ) {
let context = { "tabName": e.detail.tabName }
onTabChange?.( context )
console.log("Tab Changed to :", e.detail.tabName )
}
onMount ( () => {
hideNonSelected();
calculateIndicator();
})
$: console.log ($tabStore?.id)
</script>
<div use:styleable={$component.styles}>
Expand All @@ -111,7 +117,10 @@
class="spectrum-Tabs spectrum-Tabs--size{size}"
>
{#each _tabs as _tab}
<Tab title = {_tab._instanceName} id = {_tab._id} {emphasized}/>
<Tab
on:tabSelect={handleTabChange}
title = {_tab._instanceName}
id = {_tab._id} {emphasized}/>
{/each}
<div
Expand Down
5 changes: 4 additions & 1 deletion src/lib/Tab.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script>
import { getContext } from "svelte"
import { getContext , createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher();
const tabStore = getContext ("tabStore")
export let id
export let title
Expand All @@ -14,6 +16,7 @@
function handleClick () {
$tabStore.id = id
$tabStore.boundingBox = container?.getBoundingClientRect();
dispatch("tabSelect", {"tabID": id, "tabName": title } )
}
function init() {
if (isSelected)
Expand Down
Loading

0 comments on commit 252d713

Please sign in to comment.