Skip to content

Commit

Permalink
Dan pricing page updates (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillenberger committed May 22, 2024
1 parent 03ca54e commit 7df1e83
Show file tree
Hide file tree
Showing 28 changed files with 613 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h5 class="title"><%- title %></h5>
<ul class="list-group gap-3">
<% for bullet in bullets {%>
<div class="d-flex flex-row align-items-center gap-2">
<%+ Checkmark::new().active() %><div class="d-flex align-items-center gap-2"><%- bullet %></div>
<%+ Checkmark::new() %><div class="d-flex align-items-center gap-2"><%- bullet %></div>
</div>
<% } %>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
div[data-controller="cards-newsletter-subscribe"] {
.newsletter-subscribe-container {
background-position: center;
background-size: cover;
background-repeat: no-repeat;
@include media-breakpoint-up(md) {
background-image: url("/dashboard/static/images/newsletter_subscribe_background_desktop.png");
}
background-image: url("/dashboard/static/images/newsletter_subscribe_background_mobile.png");
background-color: #{$pink};
}

.message {
display: none;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<turbo-frame id="newsletter-subscribe-frame">
<div data-controller="cards-newsletter-subscribe">
<div class="d-flex flex-column flex-lg-row gap-5 justify-content-between align-items-center newsletter-subscribe-container py-5 ps-xl-5 px-3 rounded-4">
<div class="d-flex flex-column flex-lg-row gap-5 justify-content-between align-items-center newsletter-subscribe-container psychedelic-pink-bg py-5 ps-xl-5 px-3 rounded-4">
<div class="d-flex flex-column gap-4 text-center text-md-start w-100">
<h3>Subscribe to our newsletter.<br> (It’s better than you think)</h3>
<p>No spam. No sales pitches. Just product updates. Keep up with all our articles and news. Join our newsletter and stay up to date!</p>
Expand Down
31 changes: 29 additions & 2 deletions pgml-dashboard/src/components/icons/checkmark/checkmark.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
div[data-controller="icons-checkmark"] {
.active {
.blue {
.first {
stop-color: #3EDCFF;
}
Expand All @@ -8,7 +8,25 @@ div[data-controller="icons-checkmark"] {
}
}

.inactive {
.green {
.first {
stop-color: #44FFDD;
}
.second {
stop-color: #05C168;
}
}

.orange {
.first {
stop-color: #FFB444;
}
.second {
stop-color: #FF6644;
}
}

.white {
.first {
stop-color: #{$gray-100};
}
Expand All @@ -17,6 +35,15 @@ div[data-controller="icons-checkmark"] {
}
}

.purple {
.first {
stop-color: #5337FF;
}
.second {
stop-color: #A175FF;
}
}

.disabled {
.first {
stop-color: #{$gray-500};
Expand Down
17 changes: 7 additions & 10 deletions pgml-dashboard/src/components/icons/checkmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@ use sailfish::TemplateOnce;
#[derive(TemplateOnce, Default)]
#[template(path = "icons/checkmark/template.html")]
pub struct Checkmark {
state: String,
color: String,
twitter: bool,
disabled: bool,
}

impl Checkmark {
pub fn new() -> Checkmark {
Checkmark {
state: String::from("inactive"),
color: String::from("blue"),
twitter: false,
disabled: false,
}
}

pub fn active(mut self) -> Self {
self.state = String::from("active");
self
}

pub fn inactive(mut self) -> Self {
self.state = String::from("inactive");
pub fn color(mut self, color: &str) -> Self {
self.color = String::from(color);
self
}

pub fn disabled(mut self) -> Self {
self.state = String::from("disabled");
self.disabled = true;
self
}

Expand Down
8 changes: 7 additions & 1 deletion pgml-dashboard/src/components/icons/checkmark/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
use rand::Rng;
let mut rng = rand::thread_rng();
let id = rng.gen::<u16>();

let color_class = if disabled {
"disabled"
} else {
&color
};
%>
<div data-controller="icons-checkmark" class="d-flex">
<% if twitter {%>
Expand All @@ -10,7 +16,7 @@
</svg>
<% } else {%>

<div class="d-flex <%- state %>">
<div class="d-flex <%- color_class %>">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
<path d="M6.80486 9.80731L4.84856 7.85103C4.73197 7.73443 4.58542 7.67478 4.4089 7.67208C4.23238 7.66937 4.08312 7.72902 3.96113 7.85103C3.83913 7.97302 3.77814 8.12093 3.77814 8.29474C3.77814 8.46855 3.83913 8.61645 3.96113 8.73844L6.27206 11.0494C6.42428 11.2016 6.60188 11.2777 6.80486 11.2777C7.00782 11.2777 7.18541 11.2016 7.33764 11.0494L12.0227 6.36435C12.1393 6.24776 12.1989 6.10121 12.2016 5.92469C12.2043 5.74817 12.1447 5.59891 12.0227 5.47692C11.9007 5.35493 11.7528 5.29393 11.579 5.29393C11.4051 5.29393 11.2572 5.35493 11.1353 5.47692L6.80486 9.80731ZM8.00141 16C6.89494 16 5.85491 15.79 4.88132 15.3701C3.90772 14.9502 3.06082 14.3803 2.34064 13.6604C1.62044 12.9405 1.05028 12.094 0.63017 11.1208C0.210057 10.1477 0 9.10788 0 8.00141C0 6.89494 0.209966 5.85491 0.629896 4.88132C1.04983 3.90772 1.61972 3.06082 2.33958 2.34064C3.05946 1.62044 3.90598 1.05028 4.87915 0.630171C5.8523 0.210058 6.89212 0 7.99859 0C9.10506 0 10.1451 0.209966 11.1187 0.629897C12.0923 1.04983 12.9392 1.61972 13.6594 2.33959C14.3796 3.05946 14.9497 3.90598 15.3698 4.87915C15.7899 5.8523 16 6.89212 16 7.99859C16 9.10506 15.79 10.1451 15.3701 11.1187C14.9502 12.0923 14.3803 12.9392 13.6604 13.6594C12.9405 14.3796 12.094 14.9497 11.1208 15.3698C10.1477 15.7899 9.10788 16 8.00141 16Z" fill="url(#paint0_linear_1258_466_<%- id%>)"/>
<defs >
Expand Down
8 changes: 8 additions & 0 deletions pgml-dashboard/src/components/inputs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ pub mod labels;
pub mod radio;
pub use radio::Radio;

// src/components/inputs/range
pub mod range;
pub use range::Range;

// src/components/inputs/range_group
pub mod range_group;
pub use range_group::RangeGroup;

// src/components/inputs/range_group_pricing_calc
pub mod range_group_pricing_calc;
pub use range_group_pricing_calc::RangeGroupPricingCalc;

// src/components/inputs/range_group_v_2
pub mod range_group_v_2;
pub use range_group_v_2::RangeGroupV2;
Expand Down
85 changes: 85 additions & 0 deletions pgml-dashboard/src/components/inputs/range/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use crate::components::stimulus::StimulusTarget as Target;
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(Default)]
pub enum InterpolationType {
#[default]
Linear,
Exponential,
}

impl ToString for InterpolationType {
fn to_string(&self) -> String {
match self {
InterpolationType::Linear => String::from("linear"),
InterpolationType::Exponential => String::from("exponential"),
}
}
}

impl From<&str> for InterpolationType {
fn from(s: &str) -> Self {
match s {
"linear" => InterpolationType::Linear,
"exponential" => InterpolationType::Exponential,
_ => InterpolationType::Linear,
}
}
}

#[derive(TemplateOnce, Default)]
#[template(path = "inputs/range/template.html")]
pub struct Range {
color: String,
min: i32,
max: i32,
interpolation_type: InterpolationType,
target: Target,
initial_value: i32,
}

impl Range {
pub fn new() -> Range {
Range {
color: String::from("slate"),
min: 1000,
max: 1000000,
interpolation_type: InterpolationType::Linear,
target: Target::new(),
initial_value: 0,
}
}

pub fn color(mut self, color: &str) -> Self {
self.color = color.to_string();
self
}

pub fn min(mut self, min: i32) -> Self {
self.min = min;
self
}

pub fn max(mut self, max: i32) -> Self {
self.max = max;
self
}

pub fn interpolation_type(mut self, interpolation_type: &str) -> Self {
self.interpolation_type = InterpolationType::from(interpolation_type);
self
}

pub fn target(mut self, target: Target) -> Self {
self.target = target;
self
}

pub fn initial_value(mut self, initial_value: i32) -> Self {
self.initial_value = initial_value;
self
}
}

component!(Range);
56 changes: 56 additions & 0 deletions pgml-dashboard/src/components/inputs/range/range.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
div[data-controller="inputs-range"] {
// This allows line overhang for rounding range edges.
.overlay-offset {
width: calc(100% - 4px);
margin-left: 2px;
}

.line {
width: 100%;
height: 5px;
position: absolute;
top: 11px;
border-radius: 1rem;
}

.grab-brightness {
filter: brightness(90%) !important;
}

.range-container {
position: relative;

&:hover {
.line {
filter: brightness(110%);
}

.active-color {
filter: brightness(110%);
}
}
}

// Quick resize fix. This may become a global change later.
.input-group {
padding: 8px;
}

@mixin color_dependent($color) {
.line {
background: linear-gradient(to right, #{$color} 5%, #{$form-range-track-color} 5%);
}

.form-range {
& {
color: #{$color};
}
}
}
.slate {
@include color_dependent($slate-shade-100);
}
.neon {
@include color_dependent($neon-shade-100);
}
}
91 changes: 91 additions & 0 deletions pgml-dashboard/src/components/inputs/range/range_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
static targets = ["range", "line"];

static values = {
interpolationType: String,
min: Number,
max: Number,
initial: Number,
};

static outlets = [];

initialize() {}

connect() {
// console.log("range connected", this.initialValue)
this.rangeTarget.value =
this.interpolationTypeValue === "exponential"
? this.exponentialInterpolationSolveX(this.initialValue)
: this.linearInterpolationSolveX(this.initialValue);
}

onGrab() {
if (this.hasLineTarget) {
this.lineTarget.classList.add("grab-brightness");
}
}

onRelease() {
if (this.hasLineTarget) {
this.lineTarget.classList.remove("grab-brightness");
}
}

updateSlider(e) {
this.rangeTarget.value =
this.interpolationTypeValue === "exponential"
? this.exponentialInterpolationSolveX(e.detail)
: this.linearInterpolationSolveX(e.detail);
}

sliderMoved() {
this.dispatch("sliderMoved", {
detail:
this.interpolationTypeValue === "exponential"
? this.exponentialInterpolation(this.rangeTarget.value)
: this.linearInterpolation(this.rangeTarget.value),
});
}

exponentialInterpolation(value) {
if (value < 1) {
return 0;
}

let minValue = this.minValue > 1 ? this.minValue : 1;

let pow = value / 100;
let out = minValue * Math.pow(this.maxValue / minValue, pow);
return parseInt(Number(out.toPrecision(3)));
}

exponentialInterpolationSolveX(value) {
if (value < 1) {
return this.linearInterpolationSolveX(value);
}

let minValue = this.minValue > 1 ? this.minValue : 1;

let numerator = Math.log(value / minValue);
let denominator = Math.log(this.maxValue / minValue);
let out = (numerator / denominator) * 100;
// console.log(numerator, denominator, out, Number(out.toPrecision(3)))
return parseInt(Number(out.toPrecision(3)));
}

linearInterpolation(value) {
let out = (this.maxValue - this.minValue) * (value / 100) + this.minValue;
return parseInt(Number(out.toPrecision(3)));
}

linearInterpolationSolveX(value) {
// console.log("linear solve x ", value, this.minValue, this.maxValue)
let out = ((value - this.minValue) / (this.maxValue - this.minValue)) * 100;
return parseInt(Number(out.toPrecision(3)));
}

disconnect() {}
}

0 comments on commit 7df1e83

Please sign in to comment.