|
1 | 1 | import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; |
2 | | -import styled from "styled-components"; |
| 2 | +import styled, { css } from "styled-components"; |
3 | 3 |
|
4 | 4 | import { Address } from "viem"; |
5 | 5 |
|
6 | | -import { DropdownSelect, Field } from "@kleros/ui-components-library"; |
| 6 | +import { Copiable, DropdownSelect, Field } from "@kleros/ui-components-library"; |
7 | 7 |
|
8 | 8 | import { useRulerContext } from "context/RulerContext"; |
9 | 9 | import { shortenAddress } from "utils/shortenAddress"; |
| 10 | +import { klerosCoreAddress } from "hooks/contracts/generated"; |
| 11 | +import { DEFAULT_CHAIN } from "consts/chains"; |
| 12 | +import { landscapeStyle } from "styles/landscapeStyle"; |
10 | 13 |
|
11 | | -const Arbitrables = styled.div` |
| 14 | +const Container = styled.div` |
12 | 15 | width: 100%; |
| 16 | + display: flex; |
| 17 | + flex-wrap: wrap; |
| 18 | + justify-content: space-around; |
| 19 | + gap: 16px; |
| 20 | + align-items: center; |
| 21 | + margin: 16px 0; |
| 22 | + padding: 8px 16px; |
| 23 | + border-radius: 3px; |
13 | 24 | background-color: ${({ theme }) => theme.klerosUIComponentsWhiteBackground}; |
| 25 | +`; |
| 26 | + |
| 27 | +const AddressContainer = styled.div` |
| 28 | + display: flex; |
| 29 | + gap: 8px; |
| 30 | + flex-wrap: wrap; |
| 31 | + align-items: center; |
| 32 | + justify-content: center; |
| 33 | +`; |
| 34 | + |
| 35 | +const Arbitrables = styled.div` |
14 | 36 | display: flex; |
15 | 37 | flex-direction: row; |
16 | 38 | flex-wrap: wrap; |
17 | 39 | justify-content: center; |
18 | 40 | align-items: center; |
19 | 41 | gap: 8px; |
20 | | - margin: 16px 0; |
21 | | - padding: 8px 16px; |
22 | | - border-radius: 3px; |
23 | 42 | `; |
24 | 43 | const StyledLabel = styled.label``; |
25 | 44 |
|
26 | 45 | const SelectContainer = styled.div` |
27 | 46 | position: relative; |
28 | 47 | `; |
| 48 | + |
| 49 | +const StyledField = styled(Field)` |
| 50 | + width: auto; |
| 51 | + ${landscapeStyle( |
| 52 | + () => css` |
| 53 | + min-width: 250px; |
| 54 | + ` |
| 55 | + )} |
| 56 | +`; |
| 57 | + |
29 | 58 | const StyledDropdown = styled(DropdownSelect)` |
30 | 59 | position: absolute; |
31 | 60 | z-index: 0; |
@@ -74,20 +103,28 @@ const SelectArbitrable: React.FC = () => { |
74 | 103 | }, [knownArbitrables, ref]); |
75 | 104 |
|
76 | 105 | return ( |
77 | | - <Arbitrables suppressHydrationWarning={true}> |
78 | | - <StyledLabel>Arbitrable:</StyledLabel> |
79 | | - <SelectContainer ref={ref}> |
80 | | - <StyledDropdown defaultValue={arbitrable} items={items} callback={(val) => setArbitrable(val as Address)} /> |
81 | | - <Field |
82 | | - value={arbitrable} |
83 | | - placeholder="Enter Arbitrable" |
84 | | - onChange={(e) => { |
85 | | - setArbitrable(e.target.value as Address); |
86 | | - }} |
87 | | - onClick={openDropdown} |
88 | | - /> |
89 | | - </SelectContainer> |
90 | | - </Arbitrables> |
| 106 | + <Container> |
| 107 | + <AddressContainer> |
| 108 | + <StyledLabel>Ruler Address:</StyledLabel> |
| 109 | + <Copiable copiableContent={klerosCoreAddress[DEFAULT_CHAIN]} info="Ruler Address"> |
| 110 | + <StyledLabel>{shortenAddress(klerosCoreAddress[DEFAULT_CHAIN])}</StyledLabel> |
| 111 | + </Copiable> |
| 112 | + </AddressContainer> |
| 113 | + <Arbitrables suppressHydrationWarning={true}> |
| 114 | + <StyledLabel>Arbitrable:</StyledLabel> |
| 115 | + <SelectContainer ref={ref}> |
| 116 | + <StyledDropdown defaultValue={arbitrable} items={items} callback={(val) => setArbitrable(val as Address)} /> |
| 117 | + <StyledField |
| 118 | + value={arbitrable} |
| 119 | + placeholder="Enter Arbitrable" |
| 120 | + onChange={(e) => { |
| 121 | + setArbitrable(e.target.value as Address); |
| 122 | + }} |
| 123 | + onClick={openDropdown} |
| 124 | + /> |
| 125 | + </SelectContainer> |
| 126 | + </Arbitrables> |
| 127 | + </Container> |
91 | 128 | ); |
92 | 129 | }; |
93 | 130 |
|
|
0 commit comments