Skip to content

Commit fc88fe1

Browse files
Large style banner
1 parent 183702d commit fc88fe1

File tree

6 files changed

+133
-28
lines changed

6 files changed

+133
-28
lines changed

app/components/enterprise_edition/banner_component.html.erb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
grid.with_area(:content) do
1414
flex_layout do |flex|
1515
flex.with_row do
16-
if medium?
17-
flex_layout(align_items: :center, mb: 3) do |title_flex|
16+
if medium? || large?
17+
flex_layout(
18+
classes: "op-enterprise-banner--title-wrapper",
19+
align_items: :center,
20+
mb: 3) do |title_flex|
1821
title_flex.with_column do
1922
render(
2023
Primer::Beta::Octicon.new(
@@ -36,7 +39,10 @@
3639

3740
flex.with_row(classes: "op-enterprise-banner--description") do
3841
concat render(Primer::Beta::Text.new(tag: :p)) { description }
39-
concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }
42+
43+
unless large?
44+
concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }
45+
end
4046
end
4147

4248
if features.present?
@@ -45,8 +51,26 @@
4551
end
4652
end
4753

54+
if large?
55+
flex.with_row(my: 2) do
56+
video_tag @video,
57+
controls: false,
58+
class: "op-enterprise-banner--video-control",
59+
autoplay: true,
60+
loop: true,
61+
muted: true
62+
end
63+
64+
flex.with_row do
65+
render(Primer::Beta::Text.new(tag: :p, text_align: :center)) { plan_text }
66+
end
67+
end
68+
4869
flex.with_row(mt: 1) do
49-
render EnterpriseEdition::UpsellButtonsComponent.new(feature_key)
70+
render EnterpriseEdition::UpsellButtonsComponent.new(
71+
feature_key,
72+
justify_content: (large? ? :center : :flex_start)
73+
)
5074
end
5175
end
5276
end

app/components/enterprise_edition/banner_component.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ class BannerComponent < ApplicationComponent
4141
include PlanForFeature
4242

4343
DEFAULT_VARIANT = :inline
44-
VARIANT_OPTIONS = %i[inline medium].freeze
44+
VARIANT_OPTIONS = %i[inline medium large].freeze
4545

4646
# @param feature_key [Symbol, NilClass] The key of the feature to show the banner for.
4747
# @param variant [Symbol, NilClass] The variant of the banner comopnent.
4848
# @param image [String, NilClass] Path to the image to show on the banner, or nil.
49-
# Required when variant is :medium.
49+
# Only applicable and required when variant is :medium.
50+
# @param video [String, NilClass] Path to the video to show on the banner, or nil.
51+
# Only applicable and required when variant is :video.
5052
# @param i18n_scope [String] Provide the i18n scope to look for title, description, and features.
5153
# Defaults to "ee.upsell.{feature_key}"
5254
# @param dismissable [boolean] Allow this banner to be dismissed.
@@ -56,13 +58,15 @@ class BannerComponent < ApplicationComponent
5658
def initialize(feature_key, # rubocop:disable Metrics/AbcSize
5759
variant: DEFAULT_VARIANT,
5860
image: nil,
61+
video: nil,
5962
i18n_scope: "ee.upsell.#{feature_key}",
6063
dismissable: false,
6164
show_always: false,
6265
dismiss_key: feature_key,
6366
**system_arguments)
6467
@variant = fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)
6568
@image = image
69+
@video = video
6670
@dismissable = dismissable
6771
@dismiss_key = dismiss_key
6872
@show_always = show_always
@@ -74,6 +78,10 @@ def initialize(feature_key, # rubocop:disable Metrics/AbcSize
7478
raise ArgumentError, "The 'image' parameter is required when the variant is :medium."
7579
end
7680

81+
if @variant == :large && @video.nil?
82+
raise ArgumentError, "The 'video' parameter is required when the variant is :large."
83+
end
84+
7785
@system_arguments = system_arguments
7886
@system_arguments[:tag] = :div
7987
@system_arguments[:mb] ||= 2
@@ -82,7 +90,8 @@ def initialize(feature_key, # rubocop:disable Metrics/AbcSize
8290
@system_arguments[:classes] = class_names(
8391
@system_arguments[:classes],
8492
"op-enterprise-banner",
85-
@variant == :medium ? "op-enterprise-banner_medium" : nil
93+
@variant == :medium ? "op-enterprise-banner_medium" : nil,
94+
@variant == :large ? "op-enterprise-banner_large" : nil
8695
)
8796

8897
super
@@ -97,6 +106,10 @@ def medium?
97106
@variant == :medium
98107
end
99108

109+
def large?
110+
@variant == :large
111+
end
112+
100113
def inline?
101114
@variant == :inline
102115
end

app/components/enterprise_edition/banner_component.sass

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
/ ++
2929
/
3030
31-
$op-enterprise-banner-fixed-height: 220px
31+
$op-enterprise-banner-fixed-height-medium: 220px
32+
$op-enterprise-banner-fixed-height-large: 320px
3233

3334
.op-enterprise-banner
3435
display: grid
@@ -47,7 +48,7 @@ $op-enterprise-banner-fixed-height: 220px
4748
padding: 0
4849
grid-template-areas: "content graphic"
4950
grid-template-columns: 2fr 1fr
50-
height: $op-enterprise-banner-fixed-height
51+
height: $op-enterprise-banner-fixed-height-medium
5152

5253
@media screen and (max-width: $breakpoint-lg)
5354
grid-template-columns: 1fr
@@ -63,9 +64,38 @@ $op-enterprise-banner-fixed-height: 220px
6364
align-self: center
6465
padding: var(--base-size-16)
6566

67+
&_large
68+
position: relative
69+
padding: 0
70+
display: flex
71+
justify-content: center
72+
grid-template-areas: "content"
73+
grid-template-columns: 100%
74+
75+
&_large &
76+
&--title-wrapper
77+
justify-content: center
78+
79+
&--description
80+
text-align: center
81+
6682
&--image
6783
@include upsell-image
6884

85+
&--video-control
86+
display: block
87+
margin: 0 auto
88+
max-width: 50vw
89+
object-fit: contain
90+
box-shadow: var(--shadow-floating-small)
91+
border-radius: 25px
92+
border: 1px solid var(--borderColor-default)
93+
94+
@media screen and (max-width: $breakpoint-md)
95+
max-width: unset
96+
width: 100%
97+
border-radius: 15px
98+
6999
&--visual
70100
display: grid
71101
align-self: start
@@ -77,7 +107,7 @@ $op-enterprise-banner-fixed-height: 220px
77107

78108
&--close-icon
79109
.Button-visual
80-
color: var(--enterprise-upsell-color)
110+
color: var(--enterprise-upsell-color)
81111

82112
&_hovering
83113
position: absolute

lookbook/docs/components/enterprise.md.erb

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,6 @@ If none is provided, the link will go to the enterprise landing page on our webs
6565

6666
There are three varations of the Enterprise banner.
6767

68-
### Full-page upsell banner
69-
70-
The full-page upsell banner is used an entire page is inaccessible to the current user because their plan does not include that feature (vs. only a part of that feature not being available). The full page banner also allows us to provide a feature video or large illustration.
71-
72-
For example: when a community user clicks on the 'Team planner' module (but it's not included in their plan), or if they go to the Project admin settings and navigate to the 'Internal comments' tab under Work packages.
73-
74-
```ruby
75-
render EnterpriseEdition::UpsellPageComponent.new(
76-
:enterprise_feature,
77-
video: "enterprise/some-video.mp4",
78-
# or image: "enterprise/some-image.png"
79-
)
80-
```
81-
82-
<%= embed OpenProject::EnterpriseEdition::UpsellPageComponentPreview, :default, panels: %i[] %>
83-
8468
### Inline upsell banners
8569

8670
Inline upsell banners are useful when you want to indicate that part of a functionality or a page isn't available in the current plan. This allows the banner to be placed within a page where other parts are functional.
@@ -127,3 +111,20 @@ render EnterpriseEdition::BannerComponent.new(:enterprise_feature, variant: :med
127111
```
128112

129113
<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :medium, panels: %i[] %>
114+
115+
## Large variant banners
116+
117+
The large variant upsell banner is used an entire page is inaccessible to the current user because their plan does not include that feature (vs. only a part of that feature not being available).
118+
This banner is used when there is an illustration video present that requires this amount of space.
119+
120+
For example: when a community user clicks on the 'Team planner' module (but it's not included in their plan)
121+
122+
```ruby
123+
render EnterpriseEdition::BannerComponent.new(
124+
:enterprise_feature,
125+
variant: :large,
126+
video: "enterprise/some-video.mp4",
127+
)
128+
```
129+
130+
<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :large, panels: %i[] %>

lookbook/previews/open_project/enterprise_edition/banner_component_preview.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ def medium
7373
)
7474
end
7575

76+
# @display min_height 600px
77+
def large
78+
render(
79+
::EnterpriseEdition::BannerComponent
80+
.new(:date_alerts,
81+
variant: :large,
82+
video: "enterprise/date-alert-notifications.mp4",
83+
show_always: true)
84+
)
85+
end
86+
7687
# @display min_height 350px
7788
def medium_dismissable
7889
render(

spec/components/enterprise_edition/banner_component_spec.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787

8888
allow(OpenProject::Token)
8989
.to receive(:lowest_plan_for)
90-
.with(:some_enterprise_feature)
91-
.and_return(plan)
90+
.with(:some_enterprise_feature)
91+
.and_return(plan)
9292

9393
I18n.config.enforce_available_locales = !enforce_available_locales
9494

@@ -269,4 +269,30 @@
269269
expect(component).to have_link("More information", href: "https://example.com")
270270
end
271271
end
272+
273+
context "with large variant" do
274+
context "with video parameter" do
275+
let(:component_args) { { variant: :large, video: "enterprise/date-alert-notifications.mp4" } }
276+
277+
it_behaves_like "renders the component"
278+
279+
it "renders with large variant class" do
280+
render_component_in_mo
281+
282+
component = find_test_selector(component_test_selector)
283+
284+
expect(component[:class]).to include("op-enterprise-banner_large")
285+
end
286+
end
287+
288+
context "without video parameter" do
289+
let(:component_args) { { variant: :large } }
290+
291+
it "raises an error" do
292+
expect do
293+
render_component_in_mo
294+
end.to raise_error(ArgumentError, "The 'video' parameter is required when the variant is :large.")
295+
end
296+
end
297+
end
272298
end

0 commit comments

Comments
 (0)