import * as React from 'react'
import styled from 'styled-components'
import * as T from '@tesseract-design/react-common'
import {RightSidebarStatic} from '@theoryofnekomata/viewfinder'
import DummyContent from '../../molecules/DummyContent'
import Link from '../../molecules/Link'
import Brand from '../../molecules/Brand'

const TopBarComponent = styled('div')({
	backgroundColor: 'var(--color-bg, white)',
	'::before': {
		content: "''",
		width: '100%',
		height: '100%',
		position: 'absolute',
		top: 0,
		left: 0,
		pointerEvents: 'none',
	},
	'::after': {
		backgroundColor: 'black',
		opacity: 0.5,
		content: "''",
		width: '100%',
		height: '100%',
		position: 'absolute',
		top: 0,
		left: 0,
		pointerEvents: 'none',
	},
})

const SidebarMainComponent = styled('div')({
	backgroundColor: 'var(--color-bg, white)',
	zIndex: 2,
})

type Props = {
	query: string
	userLinkLabel: string
	searchQueryKey: string
	searchLabel: string
	searchHint: string
	popupQueryKey: string
	userPopupQueryValue: string
}

const RightSidebarLayoutTemplate: React.FC<Props> = ({
	query,
	userLinkLabel,
	searchQueryKey,
	searchLabel,
	searchHint,
	popupQueryKey,
	userPopupQueryValue,
}) => {
	return (
		<RightSidebarStatic.Layout
			brand={<Brand />}
			topBarComponent={TopBarComponent}
			sidebarMainComponent={SidebarMainComponent}
			topBarCenter={
				<form>
					<T.TextInput
						name={searchQueryKey}
						label={searchLabel}
						hint={searchHint}
						defaultValue={query}
						border
						alternate
					/>
				</form>
			}
			userLink={
				<Link
					href={{
						query: {
							[popupQueryKey]: userPopupQueryValue,
						},
					}}
				>
					<T.Icon name="user" label={userLinkLabel} />
				</Link>
			}
			sidebarMain={
				<RightSidebarStatic.SidebarMainContainer>
					<DummyContent />
				</RightSidebarStatic.SidebarMainContainer>
			}
		>
			<RightSidebarStatic.ContentContainer>
				<DummyContent />
			</RightSidebarStatic.ContentContainer>
		</RightSidebarStatic.Layout>
	)
}

export default RightSidebarLayoutTemplate