Skip to content

Commit 0eaf1ec

Browse files
authored
Merge pull request #109 from bindable-ui/cam/c-tip-disable-trigger
Disable Tip Trigger
2 parents 231609e + 536704e commit 0eaf1ec

File tree

7 files changed

+67
-4
lines changed

7 files changed

+67
-4
lines changed

dev-app/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<c-nav-horizontal-item
5353
position="right"
5454
href="https://github.com/bindable-ui/bindable"
55-
title="v1.9.9"
55+
title="v1.9.10"
5656
></c-nav-horizontal-item>
5757
</c-nav-horizontal>
5858
</l-box>

dev-app/routes/components/tip/properties/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@
105105

106106
<c-divider></c-divider>
107107

108+
<div>
109+
<l-stack spacing="var(--s-3)">
110+
<c-h3>disable-trigger</c-h3>
111+
<c-code-sample>
112+
<c-tip disable-trigger.bind="true">
113+
<div slot="trigger">
114+
<c-button>Disable Tip</c-button>
115+
</div>
116+
<div slot="content">
117+
<c-p color="var(--c_white)">Content Here will not show</c-p>
118+
</div>
119+
</c-tip>
120+
</c-code-sample>
121+
</l-stack>
122+
</div>
123+
124+
<c-divider></c-divider>
125+
108126
<div>
109127
<l-stack spacing="var(--s-3)">
110128
<c-h3>force-close</c-h3>

dev-app/routes/components/tip/properties/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ export class TipProperties {
5353
name: 'centered-content',
5454
value: 'boolean',
5555
},
56-
56+
{
57+
default: 'false',
58+
description: 'disables the tip from showing when clicked or hoover',
59+
name: 'disable-trigger',
60+
value: 'boolean',
61+
},
5762
{
5863
default: 'false',
5964
description: 'Force the tip to close when clicking anywhere after opening it.',

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@bindable-ui/bindable",
33
"description": "An Aurelia component library",
4-
"version": "1.9.9",
4+
"version": "1.9.10",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/bindable-ui/bindable"

src/components/tip/c-tip/c-tip.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,34 @@ describe('c-tip component', () => {
317317
}
318318
});
319319

320+
it('testing disableTrigger', async done => {
321+
component = StageComponent.withResources()
322+
.inView('<c-tip disable-trigger.bind="disableTrigger"></c-tip>')
323+
.boundTo({
324+
disableTrigger: true,
325+
});
326+
327+
try {
328+
await bootStrapEnvironment(component);
329+
expect(component.viewModel.disableTrigger).toBe(true);
330+
expect(component.viewModel.contentDisplay).toBe(false);
331+
332+
component.viewModel.show();
333+
expect(component.viewModel.disableTrigger).toBe(true);
334+
expect(component.viewModel.contentDisplay).toBe(false);
335+
336+
component.viewModel.contentDisplay = true;
337+
component.viewModel.disableTriggerChanged(true);
338+
339+
expect(component.viewModel.disableTrigger).toBe(true);
340+
expect(component.viewModel.contentDisplay).toBe(false);
341+
342+
done();
343+
} catch (e) {
344+
done.fail(e);
345+
}
346+
});
347+
320348
afterEach(() => {
321349
component.dispose();
322350
});

src/components/tip/c-tip/c-tip.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class CTip {
3333
public size = 'small';
3434
@bindable
3535
public contentMaxHeight = 'unset';
36+
@bindable
37+
public disableTrigger = false;
3638

3739
public styles = styles;
3840
public contentDisplay;
@@ -98,6 +100,10 @@ export class CTip {
98100
}
99101

100102
public show() {
103+
if (this.disableTrigger) {
104+
return;
105+
}
106+
101107
this.contentDisplay = true;
102108
setTimeout(() => {
103109
this.contentVisible = true;
@@ -106,4 +112,10 @@ export class CTip {
106112
}
107113
}, 100);
108114
}
115+
116+
public disableTriggerChanged(newValue) {
117+
if (newValue && this.contentDisplay) {
118+
this.contentDisplay = false;
119+
}
120+
}
109121
}

0 commit comments

Comments
 (0)