Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3ce0a98

Browse files
committedFeb 14, 2017
STENCIL-2448: Add expanded view of swatch on hover
1 parent c959917 commit 3ce0a98

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
 

‎assets/scss/layouts/products/_productSwatch.scss

+36
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,44 @@ $position_of_x : str-index($value_of_swatch_size, "x");
1212
$first_value : str-slice($value_of_swatch_size, 0, $position_of_x - 1);
1313
$second_value : str-slice($value_of_swatch_size, $position_of_x + 1);
1414

15+
[data-product-attribute] .form-option.form-option-swatch {
16+
overflow: visible;
17+
}
18+
1519
.form-option-variant--color,
1620
.form-option-variant--pattern {
1721
height: $second_value +"px";
1822
width: $first_value +"px";
1923
}
24+
25+
.form-option-expanded {
26+
background-color: stencilColor("body-bg");
27+
border: 1px solid stencilColor("input-border-color-active");
28+
left: calc(100% + 55px);
29+
opacity: 0;
30+
padding: 3px;
31+
position: absolute;
32+
top: calc(100% + 5px);
33+
transition: opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
34+
visibility: hidden;
35+
}
36+
37+
.form-option:hover {
38+
.form-option-expanded{
39+
opacity: 1;
40+
transform: translate(-50%, 0);
41+
visibility: visible;
42+
z-index: 5000;
43+
}
44+
}
45+
46+
.form-option-image {
47+
background: {
48+
position: 50%;
49+
repeat: no-repeat;
50+
size: cover;
51+
}
52+
display: block;
53+
height: 100px;
54+
width: 100px;
55+
}

‎templates/components/products/options/swatch.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
{{#each this.values}}
1212
<input class="form-radio" type="radio" name="attribute[{{../id}}]" value="{{id}}" id="attribute_{{id}}" {{#if selected}}checked{{/if}} {{#if ../required}}required{{/if}}>
13-
<label class="form-option" for="attribute_{{id}}" data-product-attribute-value="{{id}}">
13+
<label class="form-option form-option-swatch" for="attribute_{{id}}" data-product-attribute-value="{{id}}">
1414
{{#if image}}
1515
<span class='form-option-variant form-option-variant--pattern' title="{{this.label}}" style="background-image: url('{{getImage image "swatch_option_size"}}');"></span>
1616
{{/if}}
@@ -28,6 +28,11 @@
2828
{{/if}}
2929
{{/if}}
3030
{{/if}}
31+
{{#if pattern}}
32+
<span class="form-option-expanded">
33+
<span class="form-option-image" style="background-image: url('{{getImage image 'core-swatch'}}');"></span>
34+
</span>
35+
{{/if}}
3136
</label>
3237
{{/each}}
3338
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.