Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Slick card look #2531

Merged
merged 46 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cdf6680
added animation to survey cards
Dhruwang Apr 24, 2024
089bf3c
cleanup StackedCardsContainer
Dhruwang Apr 25, 2024
eaf0da8
Merge branch 'main' of https://github.com/Dhruwang/formbricks into sl…
Dhruwang Apr 25, 2024
72b18ff
tweaks
Dhruwang Apr 25, 2024
97c80b9
fix: themeStylingPreview
Dhruwang Apr 25, 2024
2920ce3
added hover effect
Dhruwang Apr 25, 2024
471856e
added icons
Dhruwang Apr 25, 2024
87469e8
Merge branch 'main' of https://github.com/Dhruwang/formbricks into sl…
Dhruwang Apr 25, 2024
e24ae34
refactor setCardArrangement
Dhruwang Apr 25, 2024
c2c0881
getTransformClasses -> calculateCardTransform
Dhruwang Apr 25, 2024
b3d516d
Merge branch 'main' into slick-card-look
jobenjada Apr 26, 2024
e8f9a7c
Merge branch 'main' of https://github.com/formbricks/formbricks into …
jobenjada Apr 29, 2024
38bddc9
small tweaks
jobenjada Apr 29, 2024
03d5238
merged main
Dhruwang May 1, 2024
93d2121
fix: card settings
Dhruwang May 1, 2024
ada3b89
Merge branch 'slick-card-look' of https://github.com/formbricks/formb…
Dhruwang May 1, 2024
07819c5
tweaks
Dhruwang May 1, 2024
4ab63ca
clean ups
Dhruwang May 1, 2024
4e791bf
tweaks
Dhruwang May 2, 2024
fc52f98
fix: e2e test
Dhruwang May 2, 2024
e6d6c61
Merge branch 'main' into slick-card-look
jobenjada May 2, 2024
e001029
fix: test
Dhruwang May 2, 2024
7ae727e
Merge branch 'slick-card-look' of https://github.com/formbricks/formb…
Dhruwang May 2, 2024
4abcf46
tweaks
jobenjada May 2, 2024
a61b5f8
Merge branch 'slick-card-look' of https://github.com/formbricks/formb…
jobenjada May 2, 2024
d413004
removed animation for simple card Arrangement
Dhruwang May 2, 2024
06bcebb
fix: scaling and cardHeight issue
Dhruwang May 2, 2024
a345081
tweaks
Dhruwang May 2, 2024
2972b56
removed invalid language component
Dhruwang May 2, 2024
6317274
remove group scale
jobenjada May 2, 2024
cb06573
fix: scale
Dhruwang May 2, 2024
2d5ed49
Merge branch 'slick-card-look' of https://github.com/formbricks/formb…
Dhruwang May 2, 2024
fc98243
Merge branch 'main' into slick-card-look
Dhruwang May 3, 2024
2d69f3d
fix: scaling
Dhruwang May 3, 2024
6dbad56
straightCardArrangamentClasses -> straightCardArranagmentStyles
Dhruwang May 3, 2024
113e3fd
Merge branch 'main' into slick-card-look
Dhruwang May 6, 2024
0e38a23
fix ttc
Dhruwang May 6, 2024
a65bd5b
Merge branch 'main' into slick-card-look
jobenjada May 6, 2024
7a8def4
fix dependency arrays and removed console log
Dhruwang May 6, 2024
76ab410
Merge branch 'slick-card-look' of https://github.com/formbricks/formb…
Dhruwang May 6, 2024
9c83624
tweaks
Dhruwang May 6, 2024
cb43897
Merge branch 'main' into slick-card-look
Dhruwang May 6, 2024
6942beb
removed unused check for closeSurveyButton
Dhruwang May 6, 2024
f526aac
fixes
Dhruwang May 7, 2024
ddd2b00
final tweaks
jobenjada May 7, 2024
0f018a7
Merge branch 'main' into slick-card-look
mattinannt May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/demo/components/SurveySwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ export const SurveySwitch = ({ value, formbricks }: SurveySwitchProps) => {
formbricks.logout();
window.location.href = `/${v}`;
}}>
<SelectTrigger className="w-[180px]">
<SelectTrigger className="w-[180px] px-4">
<SelectValue placeholder="Theme" />
</SelectTrigger>
<SelectContent>
<SelectItem value="website">Website Surveys</SelectItem>
<SelectItem value="app">App Surveys</SelectItem>
<SelectItem value="website" className="h-10 px-4 hover:bg-slate-100">
Website Surveys
</SelectItem>
<SelectItem value="app" className="hover:bg-slate-10 h-10 px-4">
App Surveys
</SelectItem>
</SelectContent>
</Select>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ThemeStyling = ({ product, environmentId, colors, isUnsplashConfigu
roundness: 8,
cardArrangement: {
linkSurveys: "simple",
inAppSurveys: "simple",
appSurveys: "simple",
},
},
});
Expand Down Expand Up @@ -132,7 +132,7 @@ export const ThemeStyling = ({ product, environmentId, colors, isUnsplashConfigu
roundness: 8,
cardArrangement: {
linkSurveys: "simple",
inAppSurveys: "simple",
appSurveys: "simple",
},
});

Expand Down Expand Up @@ -191,16 +191,17 @@ export const ThemeStyling = ({ product, environmentId, colors, isUnsplashConfigu
setOpen={setFormStylingOpen}
styling={styling}
setStyling={setStyling}
hideCheckmark
isSettingsPage
/>

<CardStylingSettings
open={cardStylingOpen}
setOpen={setCardStylingOpen}
styling={styling}
setStyling={setStyling}
hideCheckmark
isSettingsPage
localProduct={localProduct}
surveyType={previewSurveyType}
/>

<BackgroundStylingCard
Expand All @@ -211,7 +212,7 @@ export const ThemeStyling = ({ product, environmentId, colors, isUnsplashConfigu
environmentId={environmentId}
colors={colors}
key={styling.background?.bg}
hideCheckmark
isSettingsPage
isUnsplashConfigured={isUnsplashConfigured}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export const ThemeStylingPreviewSurvey = ({

const highlightBorderColor = product.styling.highlightBorderColor?.light;

function resetQuestionProgress() {
const resetQuestionProgress = () => {
setQuestionId(survey?.questions[0]?.id);
}
};

const onFileUpload = async (file: File) => file.name;

Expand All @@ -121,7 +121,7 @@ export const ThemeStylingPreviewSurvey = ({
};

return (
<div className="flex h-full w-full flex-col items-center justify-items-center">
<div className="flex h-full w-full flex-col items-center justify-items-center overflow-hidden">
<motion.div
variants={previewParentContainerVariant}
className="fixed hidden h-[95%] w-5/6"
Expand Down Expand Up @@ -158,14 +158,13 @@ export const ThemeStylingPreviewSurvey = ({
<Modal
isOpen
placement={placement}
highlightBorderColor={highlightBorderColor}
clickOutsideClose={clickOutsideClose}
darkOverlay={darkOverlay}
previewMode="desktop"
background={product.styling.cardBackgroundColor?.light}
borderRadius={product.styling.roundness ?? 8}>
<SurveyInline
survey={survey}
survey={{ ...survey, type: "app" }}
isBrandingEnabled={product.inAppSurveyBranding}
isRedirectDisabled={true}
onFileUpload={onFileUpload}
Expand All @@ -187,7 +186,7 @@ export const ThemeStylingPreviewSurvey = ({
<div
className={`${product.logo?.url && !product.styling.isLogoHidden && !isFullScreenPreview ? "mt-12" : ""} z-0 w-full max-w-md rounded-lg p-4`}>
<SurveyInline
survey={survey}
survey={{ ...survey, type: "link" }}
isBrandingEnabled={product.linkSurveyBranding}
isRedirectDisabled={true}
onFileUpload={onFileUpload}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface BackgroundStylingCardProps {
styling: TSurveyStyling | TProductStyling | null;
setStyling: React.Dispatch<React.SetStateAction<TSurveyStyling | TProductStyling>>;
colors: string[];
hideCheckmark?: boolean;
isSettingsPage?: boolean;
disabled?: boolean;
environmentId: string;
isUnsplashConfigured: boolean;
Expand All @@ -29,7 +29,7 @@ export default function BackgroundStylingCard({
styling,
setStyling,
colors,
hideCheckmark,
isSettingsPage = false,
disabled,
environmentId,
isUnsplashConfigured,
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function BackgroundStylingCard({
disabled && "cursor-not-allowed opacity-60 hover:bg-white"
)}>
<div className="inline-flex px-4 py-4">
{!hideCheckmark && (
{!isSettingsPage && (
<div className="flex items-center pl-2 pr-5">
<CheckIcon
strokeWidth={3}
Expand All @@ -89,10 +89,12 @@ export default function BackgroundStylingCard({
)}
<div className="flex flex-col">
<div className="flex items-center gap-2">
<p className="font-semibold text-slate-800">Background Styling</p>
{hideCheckmark && <Badge text="Link Surveys" type="gray" size="normal" />}
<p className={cn("font-semibold text-slate-800", isSettingsPage ? "text-sm" : "text-base")}>
Background Styling
</p>
{isSettingsPage && <Badge text="Link Surveys" type="gray" size="normal" />}
</div>
<p className="mt-1 truncate text-sm text-slate-500">
<p className={cn("mt-1 text-slate-500", isSettingsPage ? "text-xs" : "text-sm")}>
Change the background to a color, image or animation.
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import React, { useMemo } from "react";
import { cn } from "@formbricks/lib/cn";
import { COLOR_DEFAULTS } from "@formbricks/lib/styling/constants";
import { TProduct, TProductStyling } from "@formbricks/types/product";
import { TCardArrangementOptions } from "@formbricks/types/styling";
import { TSurveyStyling, TSurveyType } from "@formbricks/types/surveys";
import { Badge } from "@formbricks/ui/Badge";
import { ColorPicker } from "@formbricks/ui/ColorPicker";
import { Label } from "@formbricks/ui/Label";
import { Slider } from "@formbricks/ui/Slider";
import { ColorSelectorWithLabel } from "@formbricks/ui/Styling";
import { CardArrangement, ColorSelectorWithLabel } from "@formbricks/ui/Styling";
import { Switch } from "@formbricks/ui/Switch";

type CardStylingSettingsProps = {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
styling: TSurveyStyling | TProductStyling | null;
setStyling: React.Dispatch<React.SetStateAction<TSurveyStyling | TProductStyling>>;
hideCheckmark?: boolean;
isSettingsPage?: boolean;
surveyType?: TSurveyType;
disabled?: boolean;
localProduct: TProduct;
Expand All @@ -29,7 +30,7 @@ type CardStylingSettingsProps = {
const CardStylingSettings = ({
setStyling,
styling,
hideCheckmark,
isSettingsPage = false,
surveyType,
disabled,
open,
Expand All @@ -43,6 +44,10 @@ const CardStylingSettings = ({

const isLogoVisible = !!localProduct.logo?.url;

const linkSurveyCardArrangement = styling?.cardArrangement?.linkSurveys ?? "straight";

const inAppSurveyCardArrangement = styling?.cardArrangement?.appSurveys ?? "straight";

const setCardBgColor = (color: string) => {
setStyling((prev) => ({
...prev,
Expand Down Expand Up @@ -113,6 +118,24 @@ const CardStylingSettings = ({
}));
};

const setCardArrangement = (arrangement: TCardArrangementOptions, surveyType: TSurveyType) => {
const newCardArrangement = {
linkSurveys: linkSurveyCardArrangement,
appSurveys: inAppSurveyCardArrangement,
};

if (surveyType === "link") {
newCardArrangement.linkSurveys = arrangement;
} else if (surveyType === "app" || surveyType === "website") {
newCardArrangement.appSurveys = arrangement;
}

setStyling((prev) => ({
...prev,
cardArrangement: newCardArrangement,
}));
};

const toggleProgressBarVisibility = (hideProgressBar: boolean) => {
setStyling({
...styling,
Expand Down Expand Up @@ -147,7 +170,7 @@ const CardStylingSettings = ({
disabled && "cursor-not-allowed opacity-60 hover:bg-white"
)}>
<div className="inline-flex px-4 py-4">
{!hideCheckmark && (
{!isSettingsPage && (
<div className="flex items-center pl-2 pr-5">
<CheckIcon
strokeWidth={3}
Expand All @@ -157,8 +180,12 @@ const CardStylingSettings = ({
)}

<div>
<p className="font-semibold text-slate-800">Card Styling</p>
<p className="mt-1 text-sm text-slate-500">Style the survey card.</p>
<p className={cn("font-semibold text-slate-800", isSettingsPage ? "text-sm" : "text-base")}>
Card Styling
</p>
<p className={cn("mt-1 text-slate-500", isSettingsPage ? "text-xs" : "text-sm")}>
Style the survey card.
</p>
</div>
</div>
</Collapsible.CollapsibleTrigger>
Expand Down Expand Up @@ -198,6 +225,12 @@ const CardStylingSettings = ({
description="Change the shadow color of the card."
/>

<CardArrangement
surveyType={isAppSurvey ? "app" : "link"}
activeCardArrangement={isAppSurvey ? inAppSurveyCardArrangement : linkSurveyCardArrangement}
setActiveCardArrangement={setCardArrangement}
/>

<>
<div className="flex items-center space-x-1">
<Switch
Expand All @@ -215,14 +248,14 @@ const CardStylingSettings = ({
</Label>
</div>

{isLogoVisible && (!surveyType || surveyType === "link") && (
{isLogoVisible && (!surveyType || surveyType === "link") && !isSettingsPage && (
<div className="flex items-center space-x-1">
<Switch id="isLogoHidden" checked={isLogoHidden} onCheckedChange={toggleLogoVisibility} />
<Label htmlFor="isLogoHidden" className="cursor-pointer">
<div className="ml-2 flex flex-col">
<div className="flex items-center gap-2">
<h3 className="text-sm font-semibold text-slate-700">Hide logo</h3>
{hideCheckmark && <Badge text="Link Surveys" type="gray" size="normal" />}
<Badge text="Link Surveys" type="gray" size="normal" />
</div>
<p className="text-xs font-normal text-slate-500">
Hides the logo in this specific survey
Expand All @@ -238,8 +271,15 @@ const CardStylingSettings = ({
<Switch checked={isHighlightBorderAllowed} onCheckedChange={setIsHighlightBorderAllowed} />
<div className="flex flex-col">
<div className="flex items-center gap-2">
<h3 className="text-sm font-semibold text-slate-700">Add highlight border</h3>
<Badge text="In-App and Website Surveys" type="gray" size="normal" />
<h3 className="whitespace-nowrap text-sm font-semibold text-slate-700">
Add highlight border
</h3>
<Badge
text="App & Website Surveys"
type="gray"
size="normal"
className="whitespace-nowrap"
/>
</div>
<p className="text-xs text-slate-500">Add an outer border to your survey card.</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ type FormStylingSettingsProps = {
setStyling: React.Dispatch<React.SetStateAction<TSurveyStyling | TProductStyling>>;
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
hideCheckmark?: boolean;
isSettingsPage?: boolean;
disabled?: boolean;
};

const FormStylingSettings = ({
styling,
setStyling,
open,
hideCheckmark = false,
isSettingsPage = false,
disabled = false,
setOpen,
}: FormStylingSettingsProps) => {
Expand Down Expand Up @@ -134,7 +134,7 @@ const FormStylingSettings = ({
disabled && "cursor-not-allowed opacity-60 hover:bg-white"
)}>
<div className="inline-flex px-4 py-4">
{!hideCheckmark && (
{!isSettingsPage && (
<div className="flex items-center pl-2 pr-5">
<CheckIcon
strokeWidth={3}
Expand All @@ -144,8 +144,10 @@ const FormStylingSettings = ({
)}

<div>
<p className="font-semibold text-slate-800">Form Styling</p>
<p className="mt-1 text-sm text-slate-500">
<p className={cn("font-semibold text-slate-800", isSettingsPage ? "text-sm" : "text-base")}>
Form Styling
</p>
<p className={cn("mt-1 text-slate-500", isSettingsPage ? "text-xs" : "text-sm")}>
Style the question texts, descriptions and input fields.
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getPlacementStyle } from "@/app/lib/preview";
import { ReactNode, useEffect, useMemo, useRef, useState } from "react";
import { ReactNode, useEffect, useRef, useState } from "react";

import { cn } from "@formbricks/lib/cn";
import { TPlacement } from "@formbricks/types/common";
Expand All @@ -9,7 +9,6 @@ export default function Modal({
isOpen,
placement,
previewMode,
highlightBorderColor,
clickOutsideClose,
darkOverlay,
borderRadius,
Expand All @@ -19,7 +18,6 @@ export default function Modal({
isOpen: boolean;
placement: TPlacement;
previewMode: string;
highlightBorderColor: string | null | undefined;
clickOutsideClose: boolean;
darkOverlay: boolean;
borderRadius?: number;
Expand Down Expand Up @@ -102,14 +100,6 @@ export default function Modal({
};
}, [clickOutsideClose, scalingClasses.transformOrigin]);

const highlightBorderColorStyle = useMemo(() => {
if (!highlightBorderColor) return;

return {
border: `2px solid ${highlightBorderColor}`,
};
}, [highlightBorderColor]);

useEffect(() => {
setShow(isOpen);
}, [isOpen]);
Expand Down Expand Up @@ -144,7 +134,6 @@ export default function Modal({
<div
ref={modalRef}
style={{
...highlightBorderColorStyle,
...scalingClasses,
...(borderRadius && {
borderRadius: `${borderRadius}px`,
Expand All @@ -154,7 +143,7 @@ export default function Modal({
}),
}}
className={cn(
"no-scrollbar pointer-events-auto absolute h-fit max-h-[90%] w-full max-w-sm bg-white shadow-lg transition-all duration-500 ease-in-out ",
"no-scrollbar pointer-events-auto absolute h-fit max-h-[90%] w-full max-w-sm transition-all duration-500 ease-in-out ",
previewMode === "desktop" ? getPlacementStyle(placement) : "max-w-full",
slidingAnimationClass
)}>
Expand Down
Loading
Loading