Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix styling issues from Vanilla class disordering. #1179

Merged
merged 4 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions legacy/src/app/directives/tests/test_call_to_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ describe("maasCta", function() {

it("sets default title to 'Take action'", function() {
var directive = compileDirective("items", "active");
expect(directive.find("button.p-cta__toggle").text().trim()).toBe("Take action");
expect(directive.find("button.p-contextual-menu__toggle").text().trim()).toBe("Take action");
});

it("sets default title to another name", function() {
var name = makeName("title");
var directive = compileDirective("items", "active", null, null, name);
var selector = "button.p-cta__toggle";
var selector = "button.p-contextual-menu__toggle";
expect(directive.find(selector).text().trim()).toBe(name);
});

it("click link sets shown to true", function() {
var directive = compileDirective("items", "active");
directive.find("button.p-cta__toggle").click();
directive.find("button.p-contextual-menu__toggle").click();
expect(directive.isolateScope().shown).toBe(true);
});

it("dropdown hidden when shown is false", function() {
var directive = compileDirective("items", "active");
var dropdown = directive.find("div.p-cta__dropdown");
var dropdown = directive.find("div.p-contextual-menu__dropdown");
expect(dropdown.hasClass("ng-hide")).toBe(true);
});

Expand All @@ -104,7 +104,7 @@ describe("maasCta", function() {
directive.isolateScope().shown = true;
$scope.$digest();

var dropdown = directive.find("div.p-cta__dropdown");
var dropdown = directive.find("div.p-contextual-menu__dropdown");
expect(dropdown.hasClass("ng-hide")).toBe(false);
});

Expand All @@ -118,7 +118,7 @@ describe("maasCta", function() {

it("dropdown list options", function() {
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

var listItems = [];
angular.forEach(links, function(ele, i) {
Expand All @@ -134,10 +134,10 @@ describe("maasCta", function() {

it("dropdown select sets shown to false", function() {
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

// Open the dropdown.
directive.find("button.p-cta__toggle").click();
directive.find("button.p-contextual-menu__toggle").click();
expect(directive.isolateScope().shown).toBe(true);

// Clicking a link should close the dropdown.
Expand All @@ -147,24 +147,24 @@ describe("maasCta", function() {

it("dropdown select sets model", function() {
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

angular.element(links[0]).click();
expect(directive.scope().active).toBe($scope.items[0]);
});

it("dropdown select sets title", function() {
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

angular.element(links[0]).click();
var title = directive.find("button.p-cta__toggle").text();
var title = directive.find("button.p-contextual-menu__toggle").text();
expect(title.trim()).toBe($scope.items[0].title);
});

it("dropdown select sets secondary", function() {
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

angular.element(links[0]).click();
expect(directive.isolateScope().secondary).toBe(true);
Expand All @@ -173,7 +173,7 @@ describe("maasCta", function() {
it("dropdown select sets selectedTitle", function() {
$scope.items[0].selectedTitle = "Different if Selected";
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

var iscope = directive.isolateScope();
expect(iscope.getTitle()).toBe("Take action");
Expand All @@ -184,7 +184,7 @@ describe("maasCta", function() {
it("dropdown select sets other options' selectedTitle", function() {
$scope.items[1].selectedTitle = "Different if Selected";
var directive = compileDirective("items", "active");
var links = directive.find("button.p-cta__link");
var links = directive.find("button.p-contextual-menu__link");

var iscope = directive.isolateScope();
expect(iscope.getTitle()).toBe("Take action");
Expand All @@ -199,7 +199,7 @@ describe("maasCta", function() {
it("clicking body will set shown to false", function() {
var directive = compileDirective("items", "active");
// Open the dropdown.
directive.find("button.p-cta__toggle").click();
directive.find("button.p-contextual-menu__toggle").click();
expect(directive.isolateScope().shown).toBe(true);

// Click the body.
Expand All @@ -216,7 +216,7 @@ describe("maasCta", function() {
$scope.clicked = jasmine.createSpy("clicked");
var directive = compileDirective("items", "active", null, "clicked()");
// Open the dropdown.
directive.find("button.p-cta__toggle").click();
directive.find("button.p-contextual-menu__toggle").click();
expect($scope.clicked).toHaveBeenCalled();
});
});
19 changes: 10 additions & 9 deletions legacy/src/app/partials/directives/cta.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
<div class="p-cta">
<div class="p-contextual-menu">
<button
class="p-cta__toggle u-no-margin--right"
class="p-contextual-menu__toggle p-button--positive has-icon u-no-margin--right"
aria-controls="#cta-menu"
aria-expanded="false"
aria-haspopup="true"
data-ng-click="shown=!shown"
data-ng-class="{'p-button--positive': getTitle() === 'Take action', 'is-selected': shown}"
data-ng-disabled="disabled"
>
{$ getTitle() $}
<span>{$ getTitle() $}</span>
<i class="p-icon--contextual-menu p-contextual-menu__indicator is-light"></i>
</button>
<div
class="p-cta__dropdown"
class="p-contextual-menu__dropdown p-cta-dropdown"
id="cta-menu"
aria-hidden="false"
aria-label="submenu"
data-ng-show="shown"
>
<span class="p-cta__group" data-ng-repeat="type in getActionTypes()">
<span class="p-contextual-menu__group" data-ng-repeat="type in getActionTypes()">
<button
class="p-cta__link"
class="p-contextual-menu__link u-flex--space-between"
data-ng-repeat="select in maasCta | filter:{ type: type }"
data-ng-if="showAction(select)"
data-ng-click="selectItem(select)"
data-ng-class="{'is-unavailable': selectedItems && select.available == 0}"
>
{$ getOptionTitle(select) $}
<div class="p-cta__count" data-ng-if="showCount(select)">
<span>{$ select.available $}</span>
<span>{$ getOptionTitle(select) $}</span>
<span class="p-text--muted" data-ng-if="showCount(select)">
{$ select.available $}
</div>
</button>
</span>
Expand Down
4 changes: 2 additions & 2 deletions legacy/src/scss/_patterns_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ $vanilla-2-icon-button-side-padding: $sph-inner--small * 1.5;
}

.p-button--link {
@extend %p-button--base;

@extend %vf-button-base;
background-color: inherit;
border: 0;
color: $color-link;
line-height: 1.25rem;
Expand Down
69 changes: 2 additions & 67 deletions legacy/src/scss/_patterns_cta.scss
Original file line number Diff line number Diff line change
@@ -1,70 +1,5 @@
@mixin maas-p-cta {
%p-cta-icon {
background-position-y: center;
background-repeat: no-repeat;
background-size: map-get($icon-sizes, default);
content: "";
height: map-get($icon-sizes, default);
position: absolute;
width: map-get($icon-sizes, default);
}

.p-cta {
@extend .p-contextual-menu;
}

.p-cta__toggle {
margin-bottom: 0;
padding-right: $sph-inner * 2 + map-get($icon-sizes, default);

.page-header__controls--controllers & {
margin-bottom: 1.2rem;
}

&::after {
@extend %p-cta-icon;
@include vf-icon-chevron($color-mid-dark);
right: $sph-inner;
top: calc(#{2 * $spv-nudge} - 2px);
}

&.p-button--positive::after {
@include vf-icon-chevron($color-x-light);
}

&.is-selected::after {
transform: rotate(180deg);
}
}

.p-cta__dropdown {
@extend .p-contextual-menu__dropdown;
min-width: 100%;
top: 100%;
width: auto;
z-index: 2;
}

.p-cta__group {
& + & .p-cta__link:first-child {
border-top: 1px solid $color-mid-light;
}
}

.p-cta__link {
@extend .p-contextual-menu__link;
display: flex;
justify-content: space-between;
padding: $spv-inner--x-small $sph-inner;
transition-duration: 0s;

&.is-unavailable {
opacity: 0.5;
cursor: not-allowed;
}
}

.p-cta__count {
padding-left: $sph-inner;
.p-cta-dropdown {
margin-top: -$input-margin-bottom;
}
}
9 changes: 6 additions & 3 deletions legacy/src/scss/_patterns_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
}

&--audit {
@extend .p-icon--information;
@extend %icon;
@include vf-icon-info($color-mid-dark);
}
}

Expand All @@ -273,11 +274,13 @@
}

.p-icon--pass {
@extend .p-icon--success;
@extend %icon;
@include vf-icon-success($color-positive);
}

.p-icon--info {
@extend .p-icon--information;
@extend %icon;
@include vf-icon-info($color-mid-dark);
}

[class^="p-icon"] {
Expand Down
3 changes: 2 additions & 1 deletion legacy/src/scss/_patterns_numa.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

.p-numa__button {
@include vf-icon-plus($color-mid-dark);
@extend %p-button--base;
@extend %vf-button-base;
background-position: right center;
background-repeat: no-repeat;
background-size: map-get($icon-sizes, default);
border: 0;
margin: 0;
padding: 0 #{$sp-unit * 5} 0 0;
text-align: left;
Expand Down
4 changes: 3 additions & 1 deletion legacy/src/scss/_patterns_option-selector.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@
position: relative;

.p-option-selector__options--subnets {
@extend %p-card--highlighted;
@extend %vf-card;
@extend %vf-has-box-shadow;
@extend %vf-has-round-corners;
left: -45vw;
padding-bottom: $spv-inner--scaleable;
position: absolute;
Expand Down
16 changes: 9 additions & 7 deletions legacy/src/scss/build.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Import MAAS-specific Vanilla configuration
@import "settings";

// Import Vanilla framework
// Import and include Vanilla classes/placeholders needed for custom styling.
// NOTE: If you add another mixin here be sure to check every instance of that
// component as it alters the class ordering in Vanilla and may cause
// regressions.
@import "~vanilla-framework/scss/vanilla";
@include vf-base;
@include vf-b-placeholders;
@include vf-b-grid-definitions;
@include vf-b-typography-definitions;
@include vf-b-button;
@include vf-p-icons-common;
@include vf-p-lists;
@include vf-p-contextual-menu;
@include vf-p-icons;
@include vf-p-table-sortable;
@include vf-p-buttons;
@include vf-p-card;

@import "2.0-migration";

Expand Down
Loading