Skip to content

Commit

Permalink
Merge pull request #1979 from codecrafters-io/update-upgrade-prompt
Browse files Browse the repository at this point in the history
Update upgrade prompt to use container queries
  • Loading branch information
rohitpaulk authored Jul 17, 2024
2 parents fbcb020 + aad8dcc commit 19b1ec0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
11 changes: 5 additions & 6 deletions app/components/course-page/course-stage-step/upgrade-prompt.hbs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<div
class="py-6 px-5 rounded bg-teal-50 border border-teal-600"
class="py-6 px-5 rounded bg-teal-50 border border-teal-600 @container"
{{did-insert this.handleDidInsert}}
{{did-resize this.onResize}}
data-test-upgrade-prompt
...attributes
>
<div class="flex justify-between {{if this.isLarge 'flex-row items-center' 'flex-col'}} gap-4">
<div class="flex justify-between flex-col @[640px]:flex-row @[640px]:items-center gap-6">
<div>
<div class="font-bold text-slate-600 {{if this.isLarge 'text-2xl' 'text-xl'}}">
<div class="font-bold text-slate-600 text-xl @[640px]:text-2xl">
This stage requires a CodeCrafters Membership.
</div>

<div class="prose prose-compact py-3 {{if this.isLarge '' 'prose-sm'}}" data-test-upgrade-prompt-secondary-copy>
<div class="prose prose-compact prose-sm @[640px]:prose-base py-3" data-test-upgrade-prompt-secondary-copy>
{{#if this.isLoadingRegionalDiscount}}
<p>
Plans start at $40/mo.
Expand All @@ -27,7 +26,7 @@
</p>
</div>

<PrimaryButton class="{{if this.isLarge 'w-fit' 'w-full'}}">
<PrimaryButton class="w-full @[640px]:w-fit">
<LinkTo @route="pay">
View Membership Plans →
</LinkTo>
Expand Down
14 changes: 0 additions & 14 deletions app/components/course-page/course-stage-step/upgrade-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class UpgradePromptComponent extends Component<Signature> {
@service declare authenticator: AuthenticatorService;
@service declare store: Store;

@tracked isLarge: boolean = false;
@tracked isLoadingRegionalDiscount: boolean = true;
@tracked regionalDiscount: RegionalDiscountModel | null = null;

Expand Down Expand Up @@ -50,19 +49,6 @@ export default class UpgradePromptComponent extends Component<Signature> {
this.regionalDiscount = await this.store.createRecord('regional-discount').fetchCurrent();
this.isLoadingRegionalDiscount = false;
}

@action
onResize(entry: ResizeObserverEntry): void {
if (!entry.borderBoxSize?.[0]?.inlineSize) {
return;
}

if (entry.borderBoxSize[0].inlineSize > 680) {
this.isLarge = true;
} else {
this.isLarge = false;
}
}
}

declare module '@glint/environment-ember-loose/registry' {
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"dependencies": {
"@rails/actioncable": "^7.1.3",
"@stripe/stripe-js": "^4.1.0",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/typography": "^0.5.13",
"@typeform/embed": "^4.10.2",
"@vimeo/player": "^2.23.0",
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,5 @@ module.exports = {
width: ['group-hover'],
},
},
plugins: [require('@tailwindcss/typography')],
plugins: [require('@tailwindcss/typography'), require('@tailwindcss/container-queries')],
};

0 comments on commit 19b1ec0

Please sign in to comment.