|
1 | 1 | <template> |
2 | 2 | <div id="app"> |
3 | | - <DevTool/> |
| 3 | + <div id="devtool"> |
| 4 | + <div class="bubble" @click="showBS = true"> |
| 5 | + <font-awesome-icon class="icon" :icon="faCog"/> |
| 6 | + </div> |
| 7 | + <div class="overlay" :class="{ active: showBS }"> |
| 8 | + </div> |
| 9 | + <div class="modal" :class="{ active: showBS }"> |
| 10 | + <div class="modal-content"> |
| 11 | + <font-awesome-icon class="icon close" @click="showBS = false" :icon="faTimes"/> |
| 12 | + |
| 13 | + <div class="item" @click="reloadPage"> |
| 14 | + <font-awesome-icon class="icon" :icon="faSync"/> |
| 15 | + <span>Reload</span> |
| 16 | + </div> |
| 17 | + |
| 18 | + <div class="item" @click="openDevTools"> |
| 19 | + <font-awesome-icon class="icon" :icon="faDev"/> |
| 20 | + <span>DevTools</span> |
| 21 | + </div> |
| 22 | + |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + </div> |
4 | 26 | </div> |
5 | 27 | </template> |
6 | 28 |
|
7 | 29 | <script> |
8 | | -import DevTool from './components/DevTool.vue'; |
| 30 | +import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; |
| 31 | +import { config, dom } from '@fortawesome/fontawesome-svg-core'; |
| 32 | +import { |
| 33 | + faSync, |
| 34 | + faCog, |
| 35 | + faTimes, |
| 36 | +} from '@fortawesome/free-solid-svg-icons'; |
| 37 | +import { faDev } from '@fortawesome/free-brands-svg-icons'; |
| 38 | +
|
| 39 | +config.autoAddCss = false; |
9 | 40 |
|
10 | 41 | export default { |
11 | | - name: 'app', |
| 42 | + name: 'DevTool', |
12 | 43 | components: { |
13 | | - DevTool, |
| 44 | + FontAwesomeIcon, |
| 45 | + }, |
| 46 | + data() { |
| 47 | + return { |
| 48 | + showBS: false, |
| 49 | + }; |
| 50 | + }, |
| 51 | + computed: { |
| 52 | + faSync() { |
| 53 | + return faSync; |
| 54 | + }, |
| 55 | + faCog() { |
| 56 | + return faCog; |
| 57 | + }, |
| 58 | + faTimes() { |
| 59 | + return faTimes; |
| 60 | + }, |
| 61 | + faDev() { |
| 62 | + return faDev; |
| 63 | + }, |
| 64 | + }, |
| 65 | + methods: { |
| 66 | + reloadPage() { |
| 67 | + const event = new Event('reloadPage'); |
| 68 | + document.dispatchEvent(event); |
| 69 | + }, |
| 70 | + openDevTools() { |
| 71 | + const event = new Event('openDevTools'); |
| 72 | + document.dispatchEvent(event); |
| 73 | + }, |
| 74 | + }, |
| 75 | + mounted() { |
| 76 | + // This will only work on your root Vue component since it's using $parent |
| 77 | + const { shadowRoot } = this.$parent.$options; |
| 78 | + const id = 'fa-styles'; |
| 79 | +
|
| 80 | + if (!shadowRoot.getElementById(`${id}`)) { |
| 81 | + const faStyles = document.createElement('style'); |
| 82 | + faStyles.setAttribute('id', id); |
| 83 | + faStyles.textContent = dom.css(); |
| 84 | + shadowRoot.appendChild(faStyles); |
| 85 | + } |
14 | 86 | }, |
15 | 87 | }; |
16 | 88 | </script> |
17 | 89 |
|
18 | 90 | <style> |
19 | | -#app { |
20 | | - font-family: 'Avenir', Helvetica, Arial, sans-serif; |
21 | | - -webkit-font-smoothing: antialiased; |
22 | | - -moz-osx-font-smoothing: grayscale; |
23 | | - text-align: center; |
24 | | - color: #2c3e50; |
25 | | - margin-top: 60px; |
26 | | -} |
| 91 | + #devtool { |
| 92 | + display: flex; |
| 93 | + justify-content: center; |
| 94 | +
|
| 95 | + font-family: 'Avenir', Helvetica, Arial, sans-serif; |
| 96 | + -webkit-font-smoothing: antialiased; |
| 97 | + -moz-osx-font-smoothing: grayscale; |
| 98 | + text-align: center; |
| 99 | + color: #2c3e50; |
| 100 | + margin-top: 60px; |
| 101 | + } |
| 102 | +
|
| 103 | + .bubble { |
| 104 | + position: fixed; |
| 105 | + right: 5px; |
| 106 | + bottom: 5px; |
| 107 | +
|
| 108 | + justify-content: center; |
| 109 | +
|
| 110 | + background-color: #005fff; |
| 111 | + height: 50px; |
| 112 | + width: 50px; |
| 113 | + line-height: 50px; |
| 114 | + text-align: center; |
| 115 | + border-radius: 25px; |
| 116 | + color: #fff; |
| 117 | + cursor: pointer; |
| 118 | + } |
| 119 | +
|
| 120 | + .overlay { |
| 121 | + transition: background-color .25s; |
| 122 | + background-color: rgba(0, 0, 0, 0.0); |
| 123 | + position: fixed; |
| 124 | + top: 0; |
| 125 | + left: 0; |
| 126 | + height: 100%; |
| 127 | + width: 100%; |
| 128 | + pointer-events: none; |
| 129 | + } |
| 130 | +
|
| 131 | + .overlay.active { |
| 132 | + background-color: rgba(0, 0, 0, 0.7); |
| 133 | + } |
| 134 | +
|
| 135 | + .modal { |
| 136 | + transition: all .25s; |
| 137 | + background-color: #fff; |
| 138 | + position: fixed; |
| 139 | + bottom: -150px; |
| 140 | + height: 100px; |
| 141 | + width: 80%; |
| 142 | +
|
| 143 | + /* material card */ |
| 144 | + border-radius: 2px 2px 0 0; |
| 145 | + padding: 1rem; |
| 146 | + } |
| 147 | +
|
| 148 | + .modal.active { |
| 149 | + bottom: 0; |
| 150 | + box-shadow: 0 19px 38px rgba(0, 0, 0, 0.30), 0 15px 12px rgba(0, 0, 0, 0.22); |
| 151 | + } |
| 152 | +
|
| 153 | + .close { |
| 154 | + position: absolute; |
| 155 | + right: 5px; |
| 156 | + top: 2px; |
| 157 | + background-color: transparent; |
| 158 | + border: none; |
| 159 | + width: 16px; |
| 160 | + cursor: pointer; |
| 161 | + outline: none; |
| 162 | + } |
| 163 | +
|
| 164 | + .modal-content { |
| 165 | + display: flex; |
| 166 | + justify-content: center; |
| 167 | + align-items: center; |
| 168 | + height: 100%; |
| 169 | + } |
| 170 | +
|
| 171 | + .item { |
| 172 | + display: flex; |
| 173 | + justify-content: center; |
| 174 | + align-items: center; |
| 175 | + flex-direction: column; |
| 176 | +
|
| 177 | + border-radius: 2px; |
| 178 | + padding: 10px; |
| 179 | + margin: 15px; |
| 180 | + width: 100px; |
| 181 | + height: 50px; |
| 182 | + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); |
| 183 | +
|
| 184 | + cursor: pointer; |
| 185 | +
|
| 186 | + transition: background-color .25s; |
| 187 | + } |
| 188 | +
|
| 189 | + .item:hover { |
| 190 | + background-color: rgba(0, 0, 0, 0.12); |
| 191 | + } |
| 192 | +
|
| 193 | + .icon { |
| 194 | + width: 16px; |
| 195 | + } |
| 196 | +
|
| 197 | + .item > .icon { |
| 198 | + width: 16px; |
| 199 | + margin: 7px; |
| 200 | + } |
27 | 201 | </style> |
0 commit comments