Skip to content

Commit

Permalink
Website: add <call-to-action> component (#6244)
Browse files Browse the repository at this point in the history
* Website: add <call-to-action> component

* Lint fixes
  • Loading branch information
eashaw authored Jun 21, 2022
1 parent 286637f commit 73db2ae
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 0 deletions.
19 changes: 19 additions & 0 deletions website/assets/images/call-to-action-banner-background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions website/assets/js/components/call-to-action.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* <call-to-action>
* -----------------------------------------------------------------------------
* A customizeable call to action.
*
* @type {Component}
*
* -----------------------------------------------------------------------------
*/

parasails.registerComponent('callToAction', {
// ╔═╗╦═╗╔═╗╔═╗╔═╗
// ╠═╝╠╦╝║ ║╠═╝╚═╗
// ╩ ╩╚═╚═╝╩ ╚═╝
props: [
'title', // Required: The title of this call-to-action
'text', // Required: The text of the call to action
'primaryButtonText', // Required: The text of the call to action's button
'primaryButtonHref', // Required: the url that the call to action button leads
'secondaryButtonText', // Optional: if provided with a `secondaryButtonHref`, a second button will be added to the call to action with this value as the button text
'secondaryButtonHref', // Optional: if provided with a `secondaryButtonText`, a second button will be added to the call to action with this value as the href
],

// ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
// ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
// ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
data: function (){
let callToActionTitle = '';
let callToActionText = '';
let calltoActionPrimaryBtnText = '';
let calltoActionPrimaryBtnHref = '';
let calltoActionSecondaryBtnText = '';
let calltoActionSecondaryBtnHref = '';

return {
callToActionTitle,
callToActionText,
calltoActionPrimaryBtnText,
calltoActionPrimaryBtnHref,
calltoActionSecondaryBtnText,
calltoActionSecondaryBtnHref
};
},

// ╦ ╦╔╦╗╔╦╗╦
// ╠═╣ ║ ║║║║
// ╩ ╩ ╩ ╩ ╩╩═╝
template: `
<div>
<div purpose="cta-content" class="text-white text-center">
<div purpose="cta-title">{{callToActionTitle}}</div>
<div purpose="cta-text">{{callToActionText}}</div>
</div>
<div purpose="cta-buttons" class="mx-auto d-flex flex-sm-row flex-column justify-content-center">
<a purpose="primary-button" :class="[ secondaryButtonHref ? 'mr-sm-4 ml-sm-0' : '']" class="text-white d-sm-flex align-items-center justify-content-center btn btn-primary mx-auto":href="calltoActionPrimaryBtnHref">{{calltoActionPrimaryBtnText}}</a>
<span class="d-flex" v-if="secondaryButtonHref && secondaryButtonText">
<a purpose="secondary-button" class="btn btn-lg text-white btn-white mr-2 pl-0 mx-auto mx-sm-0 mt-2 mt-sm-0" target="_blank" :href="calltoActionSecondaryBtnHref">{{calltoActionSecondaryBtnText}}</a>
</span>
</div>
</div>
`,

// ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
// ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
// ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
beforeMount: function() {

},
mounted: async function() {
if (this.title) {
this.callToActionTitle = this.title;
} else {
throw new Error('Incomplete usage of <call-to-action>: Please provide a `title` example: title="Secure laptops & servers"');
}
if (this.text) {
this.callToActionText = this.text;
} else {
throw new Error('Incomplete usage of <call-to-action>: Please provide a `text` example: text="Get up and running with a test environment of Fleet within minutes"');
}
if (this.primaryButtonText) {
this.calltoActionPrimaryBtnText = this.primaryButtonText;
} else {
throw new Error('Incomplete usage of <call-to-action>: Please provide a `primaryButtonText`. example: primary-button-text="Get started"');
}
if (this.primaryButtonHref) {
this.calltoActionPrimaryBtnHref = this.primaryButtonHref;
} else {
throw new Error('Incomplete usage of <call-to-action>: Please provide a `primaryButtonHref` example: primary-button-href="/get-started?try-it-now"');
}
if (this.secondaryButtonText) {
this.calltoActionSecondaryBtnText = this.secondaryButtonText;
}
if (this.secondaryButtonHref) {
this.calltoActionSecondaryBtnHref = this.secondaryButtonHref;
}
},
watch: {
title: function(unused) { throw new Error('Changes to `title` are not currently supported in <call-to-action>!'); },
text: function(unused) { throw new Error('Changes to `text` are not currently supported in <call-to-action>!'); },
primaryButtonText: function(unused) { throw new Error('Changes to `primaryButtonText` are not currently supported in <call-to-action>!'); },
primaryButtonHref: function(unused) { throw new Error('Changes to `primaryButtonHref` are not currently supported in <call-to-action>!'); },
secondaryButtonText: function(unused) { throw new Error('Changes to `secondaryButtonText` are not currently supported in <call-to-action>!'); },
secondaryButtonHref: function(unused) { throw new Error('Changes to `secondaryButtonHref` are not currently supported in <call-to-action>!'); },
},
beforeDestroy: function() {
//…
},

// ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
methods: {
//…
}
});
88 changes: 88 additions & 0 deletions website/assets/styles/components/call-to-action.component.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

/**
* <call-to-action>
*
* App-wide styles for our <call-to-action> component.
*/
[parasails-component='call-to-action'] {
background-image: url('/images/call-to-action-banner-background.svg');
background-position-x: center;
background-size: cover;
background-color: #192147;
padding: 60px 90px;
border-radius: 16px;
margin-top: 40px;
margin-bottom: 40px;

[purpose='cta-content'] {
color: #FFF;
margin-bottom: 24px;
[purpose='cta-title'] {
font-weight: 900;
font-size: 28px;
line-height: 40px;
margin-bottom: 4px;
}
[purpose='cta-text'] {
font-size: 18px;
line-height: 28px;
margin-bottom: 0px;
}
}

[purpose='cta-buttons'] {
[purpose='primary-button'] {
padding: 16px 63px;
}
[purpose='secondary-button'] {
.btn-animated-arrow-red();
}
}

@media(max-width: 991px) {
padding: 60px 45px;
[purpose='cta-content'] {
[purpose='cta-title'] {
font-weight: 900;
font-size: 24px;
line-height: 32px;
margin-bottom: 4px;
}
[purpose='cta-text'] {
font-size: 16px;
line-height: 24px;
margin-bottom: 0px;
}
}
[purpose='cta-buttons'] {
[purpose='primary-button'] {
padding: 16px 63px;
}
}
}

@media(max-width: 576px) {
padding: 60px 24px;
margin-left: -16px;
margin-right: -16px;
[purpose='cta-buttons'] {
[purpose='primary-button'] {
padding: 16px 63px;
}
}
[purpose='cta-content'] {

[purpose='cta-title'] {
font-weight: 900;
font-size: 24px;
line-height: 32px;
margin-bottom: 4px;
}
[purpose='cta-text'] {
font-size: 16px;
line-height: 24px;
margin-bottom: 0px;
}
}
}
}
1 change: 1 addition & 0 deletions website/assets/styles/importer.less
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@import 'components/modal.component.less';
@import 'components/cloud-error.component.less';
@import 'components/bar-chart.component.less';
@import 'components/call-to-action.component.less';

// Per-page styles
@import 'pages/homepage.less';
Expand Down
1 change: 1 addition & 0 deletions website/scripts/build-static-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ module.exports = {
// > • What about images referenced in markdown files? :: They need to be referenced using an absolute URL src-- e.g. ![](https://fleetdm.com/images/foo.png) See also https://github.com/fleetdm/fleet/issues/706#issuecomment-884641081 for reasoning.
// > • What about GitHub-style emojis like `:white_check_mark:`? :: Use actual unicode emojis instead. Need to revisit this? Visit https://github.com/fleetdm/fleet/pull/1380/commits/19a6e5ffc70bf41569293db44100e976f3e2bda7 for more info.
let mdString = await sails.helpers.fs.read(pageSourcePath);
mdString = mdString.replace(/(<call-to-action[\s\S]+[^>\n+])\n+(>)/g, '$1$2'); // « Removes any newlines that might exist before the closing `>` when the <call-to-action> compontent is added to markdown files.
mdString = mdString.replace(/(```)([a-zA-Z0-9\-]*)(\s*\n)/g, '$1\n' + '<!-- __LANG=%' + '$2' + '%__ -->' + '$3'); // « Based on the github-flavored markdown's language annotation, (e.g. ```js```) add a temporary marker to code blocks that can be parsed post-md-compilation when this is HTML. Note: This is an HTML comment because it is easy to over-match and "accidentally" add it underneath each code block as well (being an HTML comment ensures it doesn't show up or break anything). For more information, see https://github.com/uncletammy/doc-templater/blob/2969726b598b39aa78648c5379e4d9503b65685e/lib/compile-markdown-tree-from-remote-git-repo.js#L198-L202
let htmlString = await sails.helpers.strings.toHtml(mdString);
htmlString = (// « Add the appropriate class to the `<code>` based on the temporary "LANG" markers that were just added above
Expand Down

0 comments on commit 73db2ae

Please sign in to comment.