11import React from 'react' ;
22import { FormattedMessage } from 'react-intl' ;
33import { useSelector } from 'react-redux' ;
4- import styled , { css } from 'styled-components/macro ' ;
4+ import classNames from 'classnames ' ;
55import AccessibilityButtonsWrapper from '../../components/AccessibilityButtonsWrapper' ;
66import Button from '../../components/Button' ;
77import { useServices } from '../../context/Services' ;
@@ -21,37 +21,63 @@ import { contentTextWidth } from './constants';
2121import Page from './Page' ;
2222import { PrevNextBar } from './PrevNextBar' ;
2323import { getMobileSearchFailureTop } from './Page/PageToasts' ;
24- import theme from '../../theme' ;
2524import PageToasts from './Page/PageToasts' ;
2625import {
2726 topbarDesktopHeight ,
2827 bookBannerMobileMiniHeight ,
2928} from './constants' ;
29+ import './Assigned.css' ;
3030
31- const StyledButton = styled ( Button ) `
32- width: 100%;
33- max-width: ${ contentTextWidth } rem;
34- margin: 0 auto;
35- ` ;
36-
37- // Override layout for Toast
38- const assignedMobileTop = ( props : { mobileToolbarOpen : boolean } ) =>
31+ // Helper to compute mobile toast top position
32+ const getAssignedMobileTop = ( props : { mobileToolbarOpen : boolean } ) =>
3933 getMobileSearchFailureTop ( props ) - bookBannerMobileMiniHeight ;
40- const ToastOverride = styled ( PageToasts ) `
41- top: ${ topbarDesktopHeight } rem;
42- left: 0;
43- max-width: 100%;
44- ${ theme . breakpoints . mobile ( css `
45- top : ${ assignedMobileTop } rem;
46- ` ) }
47- ` ;
48-
49- // tslint:disable-next-line: variable-name
50- const PlatformWrapper = styled . div < { platform : string } > `
51- [data-platform-hidden="${ props => props . platform } "] {
52- display: none;
53- }
54- ` ;
34+
35+ // StyledButton component - renders Button with assigned-styled-button class
36+ function StyledButton ( { className, style, ...props } : React . ComponentProps < typeof Button > ) {
37+ return (
38+ < Button
39+ { ...props }
40+ className = { classNames ( 'assigned-styled-button' , className ) }
41+ style = { {
42+ '--content-text-width' : `${ contentTextWidth } rem` ,
43+ ...style ,
44+ } as React . CSSProperties }
45+ />
46+ ) ;
47+ }
48+
49+ // ToastOverride component - renders PageToasts with overridden positioning
50+ function ToastOverride ( { className, style, mobileToolbarOpen, ...props } : React . ComponentProps < typeof PageToasts > ) {
51+ return (
52+ < PageToasts
53+ { ...props }
54+ mobileToolbarOpen = { mobileToolbarOpen }
55+ className = { classNames ( 'assigned-toast-override' , className ) }
56+ style = { {
57+ '--topbar-desktop-height' : `${ topbarDesktopHeight } rem` ,
58+ '--assigned-mobile-top' : `${ getAssignedMobileTop ( { mobileToolbarOpen } ) } rem` ,
59+ ...style ,
60+ } as React . CSSProperties }
61+ />
62+ ) ;
63+ }
64+
65+ // PlatformWrapper component - renders div with platform-specific attribute
66+ interface PlatformWrapperProps extends React . HTMLAttributes < HTMLDivElement > {
67+ platform : string ;
68+ }
69+
70+ function PlatformWrapper ( { platform, className, children, ...props } : PlatformWrapperProps ) {
71+ return (
72+ < div
73+ { ...props }
74+ data-platform = { platform }
75+ className = { classNames ( 'platform-wrapper' , className ) }
76+ >
77+ { children }
78+ </ div >
79+ ) ;
80+ }
5581
5682const useLoadSection = ( currentSection : ArchiveTreeSection | undefined ) => {
5783 const services = useServices ( ) ;
0 commit comments