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

.shepherd-popper -> .shepherd, move .shepherd-has-title #422

Merged
merged 4 commits into from
Jul 2, 2019
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: 11 additions & 21 deletions docs/welcome/css/welcome.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,28 @@ body {
width: 100%;
}

.hero-outer .hero-inner {
margin: 0 auto 1em;
text-align: center;
width: 540px;
.hero-inner {
max-width: 700px;
width: 90%;
}

@media (max-width: 600px) {
.hero-outer .hero-inner {
.hero-inner {
width: 340px;
}
}

@media (max-width: 360px) {
.hero-outer .hero-inner {
.hero-inner {
width: 200px;
}
}

.hero-outer .hero-inner {
margin: 0 auto 1em;
text-align: center;
}

.hero-outer .hero-inner h1,
.hero-outer .hero-inner h2,
.hero-outer .hero-inner h3,
Expand Down Expand Up @@ -112,20 +116,6 @@ pre {
color: rgba(0, 0, 0, 0.75);
}

.tippy-popper.shepherd-popper[x-placement^='left'] {
margin-right: 16px;
}

.tippy-popper.shepherd-popper[x-placement^='right'] {
margin-left: 16px;
}

.tippy-popper.shepherd-popper .shepherd-element:not(.shepherd-has-title) .shepherd-content header,
.tippy-popper.shepherd-popper .shepherd-element:not(.shepherd-has-title) .shepherd-content .shepherd-header {
background: transparent;
padding-bottom: 0;
}

.tippy-popper.shepherd-popper .shepherd-element .shepherd-content .shepherd-text {
.tippy-popper.shepherd .shepherd-element .shepherd-content .shepherd-text {
color: #336457;
}
1 change: 0 additions & 1 deletion src/js/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ export class Step extends Evented {
title.id = labelId;
element.setAttribute('aria-labeledby', labelId);
header.appendChild(title);
element.classList.add('shepherd-has-title');
}

content.classList.add('shepherd-content');
Expand Down
34 changes: 24 additions & 10 deletions src/js/utils/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { isString, isUndefined } from './type-check';
import tippy from 'tippy.js';
import { missingTippy } from './error-messages';

// popperOption modifier, to add shepherd-popper class to both default and centeredStyle poppers
const addShepherdClass = {
enabled: true,
fn: (data) => {
data.instance.popper.classList.add('shepherd-popper');
return data;
}
};
// popperOption modifier, to add `shepherd` class to both default and centeredStyle poppers
const addShepherdClass = _createClassModifier('shepherd');
const addHasTitleClass = _createClassModifier('shepherd-has-title');

const centeredStylePopperModifier = {
computeStyle: {
Expand Down Expand Up @@ -138,6 +133,22 @@ export function parseAttachTo() {
return returnOpts;
}

/**
* Create a popper modifier for adding the passed className to the popper
* @param {string} className The class to add to the popper
* @return {{fn(*): *, enabled: boolean}|*}
* @private
*/
function _createClassModifier(className) {
return {
enabled: true,
fn(data) {
data.instance.popper.classList.add(className);
return data;
}
};
}

/**
* Generates a `Tippy` instance from a set of base `attachTo` options
*
Expand Down Expand Up @@ -172,8 +183,7 @@ function _makeAttachedTippyOptions(attachToOptions) {
Object.assign(resultingTippyOptions, this.options.tippyOptions);

if (this.options.title) {
const existingTheme = resultingTippyOptions.theme;
resultingTippyOptions.theme = existingTheme ? `${existingTheme} shepherd-has-title` : 'shepherd-has-title';
Object.assign(defaultPopperOptions.modifiers, { addHasTitleClass });
}

if (this.options.tippyOptions && this.options.tippyOptions.popperOptions) {
Expand Down Expand Up @@ -203,6 +213,10 @@ function _makeCenteredTippy() {
tippyOptions.arrow = false;
tippyOptions.popperOptions = tippyOptions.popperOptions || {};

if (this.options.title) {
Object.assign(defaultPopperOptions.modifiers, { addHasTitleClass });
}

const finalPopperOptions = Object.assign(
{},
defaultPopperOptions,
Expand Down
12 changes: 7 additions & 5 deletions src/scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
}

&.shepherd-has-title .shepherd-content header {
background: $shepherd-header-background;
padding: 1em;
}

.shepherd-content {
background: $shepherd-text-background;
font-size: inherit;
Expand Down Expand Up @@ -112,3 +107,10 @@
}
}
}

.shepherd-has-title {
.shepherd-content header {
background: $shepherd-header-background;
padding: 1em;
}
}
4 changes: 2 additions & 2 deletions src/scss/tippy/_base-tooltips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Shepherd-Tippy tooltips have the following base structure:
*
* <div class="tippy-popper shepherd-popper" x-placement="top">
* <div class="tippy-popper shepherd" x-placement="top">
* <div class="tippy-tooltip">
* <div class="tippy-content">
* [[ Content Here ]]
Expand All @@ -12,7 +12,7 @@
* </div>
*/

.tippy-popper.shepherd-popper {
.tippy-popper.shepherd {
@include popper-theme-arrows($arrow-size: $arrow-size, $arrow-pointer-events: $arrow-pointer-events);

z-index: $shepherd-element-z-index;
Expand Down
8 changes: 4 additions & 4 deletions src/scss/tippy/_popper-theme-arrows.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
border-top-color: $text-bg;
}

.shepherd-has-title-theme {
&.shepherd-has-title {
.tippy-arrow {
border-top-color: $header-bg;
}
Expand All @@ -22,7 +22,7 @@
border-bottom-color: $text-bg;
}

.shepherd-has-title-theme {
&.shepherd-has-title {
.tippy-arrow {
border-bottom-color: $header-bg;
}
Expand All @@ -36,7 +36,7 @@
border-left-color: $text-bg;
}

.shepherd-has-title-theme {
&.shepherd-has-title {
.tippy-arrow {
border-left-color: $header-bg;
}
Expand All @@ -50,7 +50,7 @@
border-right-color: $text-bg;
}

.shepherd-has-title-theme {
&.shepherd-has-title {
.tippy-arrow {
border-right-color: $header-bg;
}
Expand Down
Loading