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

refactor(FeedbackWidget): Improve structure with Chakra UI #10997

Merged
merged 7 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
276 changes: 0 additions & 276 deletions src/components/FeedbackWidget.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/components/FeedbackWidget/FeedbackWidget.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from "react"
import { Box, Stack } from "@chakra-ui/react"
import { Meta, StoryObj } from "@storybook/react"

import FeedbackWidgetComponent from "./"

type FeedbackWidgetType = typeof FeedbackWidgetComponent

const meta = {
title: "FeedbackWidget",
parameters: {
layout: "fullscreen",
},
decorators: [
(Story) => (
<Stack minH="100vh" position="relative">
<Box flex="1" />
<Story />
</Stack>
),
],
} satisfies Meta<FeedbackWidgetType>

export default meta

export const FeedbackWidget: StoryObj<FeedbackWidgetType> = {
render: () => <FeedbackWidgetComponent />,
}
60 changes: 60 additions & 0 deletions src/components/FeedbackWidget/FixedDot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useTranslation } from "next-i18next"
import { Button, ButtonProps, ScaleFade, Text } from "@chakra-ui/react"

import { FeedbackGlyphIcon } from "../icons"

type FixedDotProps = ButtonProps & {
bottomOffset: number
isExpanded: boolean
}
const FixedDot = ({ bottomOffset, isExpanded, ...props }: FixedDotProps) => {
const { t } = useTranslation("common")
const size = "12"
return (
<Button
h={size}
w={{ base: size, lg: isExpanded ? "15rem" : size }}
borderRadius="full"
boxShadow="tableItemBox"
position="sticky"
bottom={{ base: `${bottomOffset + 1}rem`, lg: 4 }}
color="white"
ms="auto"
me="4"
mt={{ lg: "inherit" }}
zIndex={98} /* Below the mobile menu */
display="flex"
alignItems="center"
_hover={{
transform: "scale(1.1)",
transition: "transform 0.2s ease-in-out",
}}
transition="transform 0.2s ease-in-out, width 0.25s ease-in-out,
border-radius 0.25s linear"
aria-label={t("feedback-widget")}
leftIcon={<FeedbackGlyphIcon color="white" />}
iconSpacing={{ base: 0, lg: "3" }}
sx={{
".chakra-button__icon": {
me: !isExpanded ? 0 : undefined,
},
}}
{...props}
>
<ScaleFade in={isExpanded} delay={0.25}>
<Text
as="span"
fontWeight="bold"
noOfLines={2}
height="100%"
alignItems="center"
display={{ base: "none", lg: isExpanded ? "flex" : "none" }}
>
{t("feedback-widget-prompt")}
</Text>
</ScaleFade>
</Button>
)
}

export default FixedDot
Loading
Loading