-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8791968
commit 51a3b3a
Showing
6 changed files
with
153 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import clsx from "clsx"; | ||
import { FC } from "react"; | ||
|
||
interface SubscriptionPeriodButtonProps { | ||
isActive: boolean; | ||
subscriptionPeriodMode: SubscriptionPeriodMode; | ||
setSubscriptionPeriodMode: (mode: SubscriptionPeriodMode) => void; | ||
} | ||
|
||
|
||
export enum SubscriptionPeriodNames { | ||
MONTHLY = "Monthly", | ||
YEARLY = "Yearly", | ||
} | ||
|
||
export interface SubscriptionPeriodMode { | ||
name: SubscriptionPeriodNames; | ||
priceId: string; | ||
priceValueMonth: number; | ||
priceCurrency: string; | ||
} | ||
|
||
export const SubscriptionPeriodModes: SubscriptionPeriodMode[] = [ | ||
{ | ||
name: SubscriptionPeriodNames.MONTHLY, | ||
priceId: import.meta.env.VITE_PRO_PRICE_ID as string, | ||
priceValueMonth: 99.99, | ||
priceCurrency: "€", | ||
}, | ||
{ | ||
name: SubscriptionPeriodNames.YEARLY, | ||
priceId: import.meta.env.VITE_PRO_PRICE_YEARLY_ID as string, | ||
priceValueMonth: 83.33, | ||
priceCurrency: "€", | ||
}, | ||
]; | ||
|
||
const SubscriptionPeriodButton: FC<SubscriptionPeriodButtonProps> = ({ | ||
isActive, | ||
subscriptionPeriodMode, | ||
setSubscriptionPeriodMode, | ||
}) => { | ||
return ( | ||
<button | ||
type="button" | ||
className={clsx( | ||
"flex flex-row items-center gap-x-1 rounded-md px-3 py-2 text-sm font-semibold", | ||
{ | ||
"bg-blue-500 text-white shadow-md": isActive, | ||
}, | ||
)} | ||
onClick={() => setSubscriptionPeriodMode(subscriptionPeriodMode)} | ||
> | ||
<p | ||
className="w-fit-content" | ||
style={{ | ||
maxWidth: "5rem", | ||
transition: "all 0.3s ease-in-out", | ||
}} | ||
> | ||
{subscriptionPeriodMode.name} | ||
</p> | ||
</button> | ||
); | ||
}; | ||
|
||
interface SubscriptionPeriodToggleProps { | ||
subscriptionPeriodMode: SubscriptionPeriodMode; | ||
setSubscriptionPeriodMode: (mode: SubscriptionPeriodMode) => void; | ||
} | ||
|
||
const SubscriptionPeriodToggle: FC<SubscriptionPeriodToggleProps> = ({ | ||
subscriptionPeriodMode, setSubscriptionPeriodMode | ||
}) => { | ||
return ( | ||
<span className="flex flex-row gap-x-0.5 rounded-lg border border-gray-300 bg-white p-1 shadow-inner ring-1 ring-inset ring-white"> | ||
{SubscriptionPeriodModes.map((mode) => ( | ||
<SubscriptionPeriodButton | ||
key={mode.name} | ||
isActive={mode === subscriptionPeriodMode} | ||
subscriptionPeriodMode={mode} | ||
setSubscriptionPeriodMode={setSubscriptionPeriodMode} | ||
/> | ||
))} | ||
</span> | ||
); | ||
}; | ||
|
||
export default SubscriptionPeriodToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters