Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */ import React, { createContext } from 'react'; import { Inventory, useInventory } from '@lib/components/Inventory'; import { Game } from '@uniquegood/realworld-web-interface/lib/models/game'; import CSSTransition from 'react-transition-group/CSSTransition'; import { createPortal } from 'react-dom'; import { css } from '@emotion/react'; const ANIMATION_DURATION = 500; const InventoryContext = createContext<{ openInventory: () => unknown; }>({ openInventory: async () => { // pass } }); export const useInventoryContext = () => React.useContext(InventoryContext); export function InventoryProvider({ children, game }: { children: React.ReactNode; game: Game }) { const { props: inventoryProps, openInventory } = useInventory(); const value = React.useMemo(() => ({ openInventory }), [openInventory]); const portalRef = React.useRef<HTMLDivElement>(null); return ( <InventoryContext.Provider value={value}> {children} <CSSTransition nodeRef={portalRef} in={inventoryProps.isOpen} timeout={ANIMATION_DURATION} unmountOnExit > <> {createPortal( <div ref={portalRef} css={portalWrap} onClick={inventoryProps.onClose}> <div css={container} className="container" onClick={(e) => e.stopPropagation()}> <div css={headerContainer}> <div css={titleWrap}>아이템 목록</div> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" onClick={inventoryProps.onClose} css={closeIconWrap} > <path css={closeIconFill} d="M13.1 11.9998L19.6 5.4998C19.9 5.1998 19.9 4.6998 19.6 4.3998C19.3 4.0998 18.8 4.0998 18.5 4.3998L12 10.8998L5.50005 4.4998C5.20005 4.1998 4.70005 4.1998 4.40005 4.4998C4.10005 4.7998 4.10005 5.2998 4.40005 5.5998L10.9 12.0998L4.40005 18.5998C4.10005 18.8998 4.10005 19.3998 4.40005 19.6998C4.50005 19.7998 4.70005 19.8998 4.90005 19.8998C5.10005 19.8998 5.30005 19.7998 5.40005 19.6998L11.9 13.1998L18.4 19.6998C18.5 19.7998 18.7 19.8998 18.9 19.8998C19.1 19.8998 19.3 19.7998 19.4 19.6998C19.7 19.3998 19.7 18.8998 19.4 18.5998L13.1 11.9998Z" /> </svg> </div> {inventoryProps && ( <Inventory {...inventoryProps} itemList={game.itemList} itemTag={game.itemTag} /> )} </div> </div>, document.body )} </> </CSSTransition> </InventoryContext.Provider> ); } const portalWrap = css` position: fixed; top: 0; left: 0; z-index: 1000; width: 100%; height: 100%; display: flex; justify-content: center; align-items: flex-end; background-color: rgba(0, 0, 0, 0.5); &.enter { background-color: rgba(0, 0, 0, 0); .container { transform: translateY(100%); } } &.enter-active { background-color: rgba(0, 0, 0, 0.5); transition: background-color ${ANIMATION_DURATION}ms ease-in-out; .container { transform: translateY(0%); transition: transform ${ANIMATION_DURATION}ms ease-in-out; } } &.exit { background-color: rgba(0, 0, 0, 0.5); } &.exit-active { background-color: rgba(0, 0, 0, 0); transition: background-color ${ANIMATION_DURATION}ms ease-in-out; .container { transform: translateY(100%); transition: transform ${ANIMATION_DURATION}ms ease-in-out; } } `; const container = css` display: flex; flex-direction: column; color: var(--theme-gpsMap-color); word-break: keep-all; overflow: hidden; background: var(--theme-inventory-data-rsbs-overlay-background-color); width: min(calc(100% - 10px), calc(calc(100vh - 52px) * 0.5625)); height: 85%; border-radius: 24px 24px 0 0; padding-top: 24px; `; const titleWrap = css` font-family: Pretendard, sans-serif; font-size: 18px; font-style: normal; font-weight: 700; line-height: 24px; /* 133.333% */ `; const headerContainer = css` display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; `; const closeIconWrap = css` cursor: pointer; `; const closeIconFill = css` fill: var(--theme-inventory-closeIcon-fill); `; |