Merged in feat/sw-2873-move-backtotopbutton-to-design-system (pull request #2593)
feat(SW-2873): Move BackToTopButton to design-system * Remove dependency on i18n in BackToTopButton * Move BackToTopButton to design-system Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { useRef } from "react"
|
import { useRef } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
import { AlertTypeEnum } from "@scandic-hotels/trpc/types/alertType"
|
||||||
|
|
||||||
@@ -10,7 +11,6 @@ import { useDestinationDataStore } from "@/stores/destination-data"
|
|||||||
|
|
||||||
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { BackToTopButton } from "@/components/TempDesignSystem/BackToTopButton"
|
|
||||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||||
|
|
||||||
import CityListingItem from "./CityListingItem"
|
import CityListingItem from "./CityListingItem"
|
||||||
@@ -69,7 +69,13 @@ export default function CityListing() {
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
{showBackToTop ? (
|
{showBackToTop ? (
|
||||||
<BackToTopButton position="right" onClick={scrollToTop} />
|
<BackToTopButton
|
||||||
|
position="right"
|
||||||
|
onClick={scrollToTop}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Back to top",
|
||||||
|
})}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useParams } from "next/navigation"
|
|||||||
import { useEffect, useRef, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
@@ -14,7 +15,6 @@ import { useDestinationDataStore } from "@/stores/destination-data"
|
|||||||
|
|
||||||
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
||||||
import Alert from "@/components/TempDesignSystem/Alert"
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { BackToTopButton } from "@/components/TempDesignSystem/BackToTopButton"
|
|
||||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||||
|
|
||||||
import HotelListingItem from "./HotelListingItem"
|
import HotelListingItem from "./HotelListingItem"
|
||||||
@@ -100,7 +100,13 @@ export default function HotelListing() {
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
{showBackToTop ? (
|
{showBackToTop ? (
|
||||||
<BackToTopButton position="right" onClick={scrollToTop} />
|
<BackToTopButton
|
||||||
|
position="right"
|
||||||
|
onClick={scrollToTop}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Back to top",
|
||||||
|
})}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "react"
|
} from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
||||||
|
|
||||||
@@ -18,7 +19,6 @@ import { useDestinationDataStore } from "@/stores/destination-data"
|
|||||||
import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map"
|
import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map"
|
||||||
|
|
||||||
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
import DestinationFilterAndSort from "@/components/DestinationFilterAndSort"
|
||||||
import { BackToTopButton } from "@/components/TempDesignSystem/BackToTopButton"
|
|
||||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||||
import { debounce } from "@/utils/debounce"
|
import { debounce } from "@/utils/debounce"
|
||||||
|
|
||||||
@@ -157,7 +157,13 @@ export default function Map({
|
|||||||
<aside className={styles.sidebar} ref={scrollRef}>
|
<aside className={styles.sidebar} ref={scrollRef}>
|
||||||
{children}
|
{children}
|
||||||
{showBackToTop ? (
|
{showBackToTop ? (
|
||||||
<BackToTopButton position="left" onClick={scrollToTop} />
|
<BackToTopButton
|
||||||
|
position="left"
|
||||||
|
onClick={scrollToTop}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Back to top",
|
||||||
|
})}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</aside>
|
</aside>
|
||||||
<DynamicMap
|
<DynamicMap
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
import { useSearchParams } from "next/navigation"
|
import { useSearchParams } from "next/navigation"
|
||||||
import { useSession } from "next-auth/react"
|
import { useSession } from "next-auth/react"
|
||||||
import { useEffect, useMemo, useRef } from "react"
|
import { useEffect, useMemo, useRef } from "react"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
|
|
||||||
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
|
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
|
||||||
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
||||||
import { useHotelsMapStore } from "@/stores/hotels-map"
|
import { useHotelsMapStore } from "@/stores/hotels-map"
|
||||||
|
|
||||||
import { BackToTopButton } from "@/components/TempDesignSystem/BackToTopButton"
|
|
||||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||||
import { isValidClientSession } from "@/utils/clientSession"
|
import { isValidClientSession } from "@/utils/clientSession"
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ export default function HotelCardListing({
|
|||||||
type = HotelCardListingTypeEnum.PageListing,
|
type = HotelCardListingTypeEnum.PageListing,
|
||||||
isAlternative,
|
isAlternative,
|
||||||
}: HotelCardListingProps) {
|
}: HotelCardListingProps) {
|
||||||
|
const intl = useIntl()
|
||||||
const { data: session } = useSession()
|
const { data: session } = useSession()
|
||||||
const isUserLoggedIn = isValidClientSession(session)
|
const isUserLoggedIn = isValidClientSession(session)
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
@@ -140,7 +143,13 @@ export default function HotelCardListing({
|
|||||||
))
|
))
|
||||||
: null}
|
: null}
|
||||||
{showBackToTop && (
|
{showBackToTop && (
|
||||||
<BackToTopButton position="right" onClick={scrollToTop} />
|
<BackToTopButton
|
||||||
|
position="right"
|
||||||
|
onClick={scrollToTop}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Back to top",
|
||||||
|
})}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useCallback, useMemo, useRef, useState } from "react"
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
import { useMediaQuery } from "usehooks-ts"
|
import { useMediaQuery } from "usehooks-ts"
|
||||||
|
|
||||||
|
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton"
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@ import { useHotelsMapStore } from "@/stores/hotels-map"
|
|||||||
|
|
||||||
import { RoomCardSkeleton } from "@/components/HotelReservation/RoomCardSkeleton/RoomCardSkeleton"
|
import { RoomCardSkeleton } from "@/components/HotelReservation/RoomCardSkeleton/RoomCardSkeleton"
|
||||||
import InteractiveMap from "@/components/Maps/InteractiveMap"
|
import InteractiveMap from "@/components/Maps/InteractiveMap"
|
||||||
import { BackToTopButton } from "@/components/TempDesignSystem/BackToTopButton"
|
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||||
@@ -203,7 +203,13 @@ export default function SelectHotelContent({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{showBackToTop && (
|
{showBackToTop && (
|
||||||
<BackToTopButton position="left" onClick={scrollToTop} />
|
<BackToTopButton
|
||||||
|
position="left"
|
||||||
|
onClick={scrollToTop}
|
||||||
|
label={intl.formatMessage({
|
||||||
|
defaultMessage: "Back to top",
|
||||||
|
})}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<InteractiveMap
|
<InteractiveMap
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import type { VariantProps } from "class-variance-authority"
|
|
||||||
import type { ComponentProps } from "react"
|
|
||||||
import type { Button } from "react-aria-components"
|
|
||||||
|
|
||||||
import type { backToTopButtonVariants } from "./variants"
|
|
||||||
|
|
||||||
export interface BackToTopButtonProps
|
|
||||||
extends ComponentProps<typeof Button>,
|
|
||||||
VariantProps<typeof backToTopButtonVariants> {}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import { Button as ButtonRAC } from "react-aria-components"
|
|
||||||
import { useIntl } from "react-intl"
|
|
||||||
|
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
|
||||||
|
|
||||||
import { backToTopButtonVariants } from "./variants"
|
|
||||||
|
|
||||||
import styles from "./backToTopButton.module.css"
|
|
||||||
|
|
||||||
import type { BackToTopButtonProps } from "./backToTopButton"
|
|
||||||
|
|
||||||
export function BackToTopButton({ position, ...props }: BackToTopButtonProps) {
|
|
||||||
const intl = useIntl()
|
|
||||||
return (
|
|
||||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
|
||||||
<ButtonRAC
|
|
||||||
className={backToTopButtonVariants({ position })}
|
|
||||||
aria-label={intl.formatMessage({
|
|
||||||
defaultMessage: "Back to top",
|
|
||||||
})}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<MaterialIcon icon="arrow_upward" color="CurrentColor" size={20} />
|
|
||||||
<span className={styles.text}>
|
|
||||||
{intl.formatMessage({
|
|
||||||
defaultMessage: "Back to top",
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</ButtonRAC>
|
|
||||||
</Typography>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { type Button, Button as ButtonRAC } from 'react-aria-components'
|
||||||
|
|
||||||
|
import { MaterialIcon } from '../Icons/MaterialIcon'
|
||||||
|
import { Typography } from '../Typography'
|
||||||
|
|
||||||
|
import { backToTopButtonVariants } from './variants'
|
||||||
|
|
||||||
|
import styles from './backToTopButton.module.css'
|
||||||
|
|
||||||
|
import type { VariantProps } from 'class-variance-authority'
|
||||||
|
import type { ComponentProps } from 'react'
|
||||||
|
|
||||||
|
interface BackToTopButtonProps
|
||||||
|
extends ComponentProps<typeof Button>,
|
||||||
|
VariantProps<typeof backToTopButtonVariants> {
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BackToTopButton({
|
||||||
|
position,
|
||||||
|
label,
|
||||||
|
...props
|
||||||
|
}: BackToTopButtonProps) {
|
||||||
|
return (
|
||||||
|
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||||
|
<ButtonRAC
|
||||||
|
className={backToTopButtonVariants({ position })}
|
||||||
|
aria-label={label}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<MaterialIcon icon="arrow_upward" color="CurrentColor" size={20} />
|
||||||
|
<span className={styles.text}>{label}</span>
|
||||||
|
</ButtonRAC>
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cva } from "class-variance-authority"
|
import { cva } from 'class-variance-authority'
|
||||||
|
|
||||||
import styles from "./backToTopButton.module.css"
|
import styles from './backToTopButton.module.css'
|
||||||
|
|
||||||
export const backToTopButtonVariants = cva(styles.backToTopButton, {
|
export const backToTopButtonVariants = cva(styles.backToTopButton, {
|
||||||
variants: {
|
variants: {
|
||||||
@@ -11,6 +11,6 @@ export const backToTopButtonVariants = cva(styles.backToTopButton, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
position: "right",
|
position: 'right',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
"version": "1.0.0-beta.1",
|
"version": "1.0.0-beta.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./BackToTopButton": "./dist/components/BackToTopButton/index.js",
|
||||||
"./Body": "./dist/components/Body/index.js",
|
"./Body": "./dist/components/Body/index.js",
|
||||||
"./Button": "./dist/components/Button/index.js",
|
"./Button": "./dist/components/Button/index.js",
|
||||||
"./Caption": "./dist/components/Caption/index.js",
|
"./Caption": "./dist/components/Caption/index.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user