|
| 1 | +import { createGlobalStyle, css } from "styled-components"; |
| 2 | + |
| 3 | +const light = css` |
| 4 | + :root { |
| 5 | + --primary: #7b79ff; |
| 6 | + --secondary: rgb(255, 255, 255); |
| 7 | + --text: #32324d; |
| 8 | + --input-background: #ffffff; |
| 9 | + --input-border: #dcdce4; |
| 10 | + --tag-background: #f0f0ff; |
| 11 | + --tag-text: #4945ff; |
| 12 | + --suggestion-background: #ffffff; |
| 13 | + --suggestion-hover: #f6f6f9; |
| 14 | + } |
| 15 | +`; |
| 16 | + |
| 17 | +const dark = css` |
| 18 | + :root { |
| 19 | + --primary: #7b79ff; |
| 20 | + --secondary: rgb(33, 33, 52); |
| 21 | + --text: #ffffff; |
| 22 | + --input-background: #181826; |
| 23 | + --input-border: #4a4a6a; |
| 24 | + --tag-background: #7b79ff; |
| 25 | + --tag-text: #ffffff; |
| 26 | + --suggestion-background: #181826; |
| 27 | + --suggestion-hover: #212134; |
| 28 | + } |
| 29 | +`; |
| 30 | + |
| 31 | +const styles = css` |
| 32 | + .react-tagsinput { |
| 33 | + width: 100%; |
| 34 | + border: 1px solid var(--input-border); |
| 35 | + border-radius: 4px; |
| 36 | + overflow: hidden; |
| 37 | + padding-left: 5px; |
| 38 | + padding-top: 5px; |
| 39 | + } |
| 40 | +
|
| 41 | + .react-tagsinput--focused { |
| 42 | + outline: 3px solid var(--primary); |
| 43 | + } |
| 44 | +
|
| 45 | + .react-tagsinput-tag { |
| 46 | + background-color: var(--tag-background); |
| 47 | + border-radius: 2px; |
| 48 | + border: 1px solid var(--tag-background); |
| 49 | + color: var(--tag-text); |
| 50 | + display: inline-block; |
| 51 | + font-family: sans-serif; |
| 52 | + font-size: 13px; |
| 53 | + font-weight: 400; |
| 54 | + margin-bottom: 5px; |
| 55 | + margin-right: 5px; |
| 56 | + padding: 5px; |
| 57 | + } |
| 58 | +
|
| 59 | + .react-tagsinput-remove { |
| 60 | + cursor: pointer; |
| 61 | + font-weight: bold; |
| 62 | + } |
| 63 | +
|
| 64 | + .react-tagsinput-tag a::before { |
| 65 | + content: " ×"; |
| 66 | + } |
| 67 | +
|
| 68 | + .react-tagsinput-input { |
| 69 | + background: transparent; |
| 70 | + border: 0; |
| 71 | + color: var(--text); |
| 72 | + font-family: sans-serif; |
| 73 | + font-size: 13px; |
| 74 | + font-weight: 400; |
| 75 | + margin-bottom: 6px; |
| 76 | + margin-top: 1px; |
| 77 | + outline: none; |
| 78 | + padding: 5px; |
| 79 | + width: 100%; |
| 80 | + } |
| 81 | +
|
| 82 | + .react-tagsinput > span { |
| 83 | + display: flex; |
| 84 | + flex-flow: wrap; |
| 85 | + } |
| 86 | +
|
| 87 | + .react-autosuggest__container { |
| 88 | + display: flex; |
| 89 | + flex-direction: column; |
| 90 | + flex: auto; |
| 91 | + } |
| 92 | +
|
| 93 | + .react-autosuggest__suggestions-container { |
| 94 | + position: absolute; |
| 95 | + z-index: 200; |
| 96 | + width: 280px; |
| 97 | + margin: 0; |
| 98 | + padding: 0; |
| 99 | + list-style-type: none; |
| 100 | + background-color: var(--suggestion-background); |
| 101 | + } |
| 102 | +
|
| 103 | + .react-autosuggest__suggestions-container--open { |
| 104 | + border: 1px solid var(--input-border); |
| 105 | + } |
| 106 | +
|
| 107 | + .react-autosuggest__suggestion { |
| 108 | + cursor: pointer; |
| 109 | + padding: 10px 20px; |
| 110 | + } |
| 111 | +
|
| 112 | + .react-autosuggest__suggestion > span { |
| 113 | + font-size: 13px; |
| 114 | + font-weight: 400; |
| 115 | + } |
| 116 | +
|
| 117 | + .react-autosuggest__suggestion--highlighted, |
| 118 | + .react-autosuggest__suggestion--focused { |
| 119 | + background-color: var(--suggestion-hover); |
| 120 | + } |
| 121 | +`; |
| 122 | + |
| 123 | +export const getStyling = (theme) => { |
| 124 | + let themeStyle = light; |
| 125 | + |
| 126 | + switch (theme) { |
| 127 | + case 'dark': |
| 128 | + themeStyle = dark; |
| 129 | + break; |
| 130 | + default: |
| 131 | + themeStyle = light; |
| 132 | + } |
| 133 | + |
| 134 | + return createGlobalStyle` |
| 135 | + ${themeStyle} |
| 136 | + ${styles} |
| 137 | + `; |
| 138 | +}; |
0 commit comments