Skip to content

Commit 7242435

Browse files
authored
Merge pull request #775 from BY00565233/SURF-2067
feat(beacon): implement override option for default styles
2 parents 96c0125 + db0a69d commit 7242435

File tree

4 files changed

+110
-4
lines changed

4 files changed

+110
-4
lines changed

docs/components/beacon/beacon-demo.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,49 @@ import Util from '../../_util';
7070
},
7171
});
7272
}//vue-beacon-inline-styles
73+
74+
if (document.getElementById('vue-beacon-Override-styles')) {
75+
new Vue({
76+
el: '#vue-beacon-Override-styles',
77+
data: {
78+
beaconOverrideStyles: 'top: 42%; left: 24px; --hxBeacon: #d32f2f;',
79+
isOpen: false,
80+
isDismissed: false,
81+
},
82+
methods: {
83+
onEvent: function () {
84+
this.isOpen = true;
85+
this.isDismissed = true;
86+
},
87+
88+
},
89+
computed: {
90+
beaconOverrideSnippet: function () {
91+
if (this.isDismissed) {
92+
return '';
93+
} else {
94+
return `<hx-beacon style="${this.beaconOverrideStyles}"></hx-beacon>`;
95+
}
96+
},
97+
snippetOverrideStyles: function () {
98+
return Util.snippet(`
99+
<!-- Providing a border around the <div> for illustration -->
100+
<div style="position: relative;">
101+
${this.beaconOverrideSnippet}
102+
<hx-disclosure class="hxBtn" aria-controls="overrideMenuId">
103+
<hx-icon type="cog"></hx-icon>
104+
<span>Actions</span>
105+
<hx-icon class="hxPrimary" type="angle-down"></hx-icon>
106+
</hx-disclosure>
107+
<hx-menu id="overrideMenuId">
108+
<hx-menuitem>Action 1</hx-menuitem>
109+
<hx-menuitem>Action 2</hx-menuitem>
110+
<hx-menuitem>Action 3</hx-menuitem>
111+
</hx-menu>
112+
</div>
113+
`);
114+
},
115+
},
116+
});
117+
}//vue-beacon-Override-styles
73118
})();

docs/components/beacon/index.html

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ <h2 id="basic-beacon">Basic Beacon</h2>
3636
</div>
3737
</section>
3838

39-
4039
<section>
4140
<header>
4241
<h2 id="beacon-with-inline-styles">Beacon with Inline Styles</h2>
@@ -100,4 +99,66 @@ <h2 id="beacon-with-inline-styles">Beacon with Inline Styles</h2>
10099
</footer>
101100
</div>
102101
</section>
102+
103+
<section>
104+
<header>
105+
<h2 id="beacon-with-color-override">Beacon with Color Override</h2>
106+
</header>
107+
<p>
108+
This is an example implementation of <code>&lt;hx-beacon&gt;</code>
109+
With color override.
110+
Hexidecimal or named color values are valid, though hex values are
111+
best practice for consistency.
112+
</p>
113+
<p class="hxSubdued hxSubBody">
114+
<hx-icon type="exclamation-triangle"></hx-icon>
115+
User can use <b>--hxBeacon</b> property for overriding the default Beacon
116+
component color.
117+
(Example:<b>--hxBeacon:#d32f2f or --hxBeacon:red</b>)
118+
</p>
119+
<div class="example" id="vue-beacon-Override-styles" v-cloak>
120+
<header>
121+
<form class="beta-hxForm">
122+
<fieldset>
123+
<hx-text-control>
124+
<input
125+
id="txtBeaconOverrideStyles"
126+
type="text"
127+
v-model="beaconOverrideStyles"
128+
/>
129+
<label for="txtBeaconOverrideStyles">
130+
Beacon Inline Styles
131+
</label>
132+
</hx-text-control>
133+
<p class="hxSubdued hxSubBody">
134+
<hx-icon type="info-circle"></hx-icon>
135+
Hexadecimal and named colors are valid values.
136+
</p>
137+
</fieldset>
138+
</form>
139+
</header>
140+
141+
<div style="position: relative; border: 1px dashed black;"> <!-- demo snippet -->
142+
<hx-beacon
143+
@dismiss="onEvent"
144+
:style="beaconOverrideStyles"
145+
>
146+
</hx-beacon>
147+
<hx-disclosure class="hxBtn" aria-controls="overrideMenuId">
148+
<hx-icon type="cog"></hx-icon>
149+
<span>Actions</span>
150+
<hx-icon class="hxPrimary" type="angle-down"></hx-icon>
151+
</hx-disclosure>
152+
<hx-menu id="overrideMenuId" :open="isOpen">
153+
<hx-menuitem>Action 1</hx-menuitem>
154+
<hx-menuitem>Action 2</hx-menuitem>
155+
<hx-menuitem>Action 3</hx-menuitem>
156+
</hx-menu>
157+
</div>
158+
159+
<footer>
160+
<pre><code v-text="snippetOverrideStyles"></code></pre>
161+
</footer>
162+
</div>
163+
</section>
103164
{% endblock %}

src/elements/hx-beacon/_shadow.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
-webkit-animation: hx-pulse 2s infinite linear;
1212
animation: hx-pulse 2s infinite linear;
1313
border-radius: 3rem;
14-
box-shadow: 0 0 1px 1px $gray-750;
14+
box-shadow: 0 0 1px 1px var(--hxBeacon, $gray-750);
1515
content: "";
1616
height: 1rem;
1717
left: 0;

src/scss/components/beacon/index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
/// ========== hxBeacon ========== ///
55
hx-beacon {
6-
background-color: $gray-0;
6+
background-color: var(--hxBeacon, $gray-0);
77
border-radius: 1rem;
8-
box-shadow: 0 0 2px 2px $gray-600;
8+
box-shadow: 0 0 2px 2px var(--hxBeacon, $gray-600);
99
display: block;
1010
height: 1rem;
1111
margin: 0;

0 commit comments

Comments
 (0)