Просмотр исходного кода

Fix picker style for dark/light mode and better fit in gadget window

pull/1/head
Garrick Aden-Buie 5 лет назад
Родитель
Сommit
c923b394f4
2 измененных файлов: 11 добавлений и 4 удалений
  1. +6
    -3
      R/emoji_picker.R
  2. +5
    -1
      inst/picker/emoji-picker.js

+ 6
- 3
R/emoji_picker.R Просмотреть файл

shiny::tags$script(src = "eb/emoji-picker.js", type = "module"), shiny::tags$script(src = "eb/emoji-picker.js", type = "module"),
shiny::tags$head( shiny::tags$head(
shiny::tags$script(src = 'eb/he.js'), shiny::tags$script(src = 'eb/he.js'),
shiny::tags$style('.emoji-picker__plugin-container { justify-content: space-between; }')
shiny::tags$style(
'.emoji-picker__plugin-container { justify-content: space-between; }
.emoji-picker { border-radius: 0 !important; }'
)
) )
) )
} }
theme <- rstudioapi::getThemeInfo() theme <- rstudioapi::getThemeInfo()
shiny::tags$style(shiny::HTML(paste0( shiny::tags$style(shiny::HTML(paste0(
".emoji-picker {\n", ".emoji-picker {\n",
" --background-color: ", theme$background, ";\n",
" --text-color: ", theme$foreground, ";\n",
if (theme$dark) " --dark-background-color: " else " --background-color: ", theme$background, ";\n",
if (theme$dark) " --dark-text-color: " else " --text-color: ", theme$foreground, ";\n",
"}\n", "}\n",
"body { background-color: ", theme$background, "; color: ", theme$foreground, ";}\n", "body { background-color: ", theme$background, "; color: ", theme$foreground, ";}\n",
"#picker_type {\n", "#picker_type {\n",

+ 5
- 1
inst/picker/emoji-picker.js Просмотреть файл



picker.togglePicker(document.getElementById('emoji-picker')) picker.togglePicker(document.getElementById('emoji-picker'))


document.querySelector('.emoji-picker__wrapper').addEventListener('keydown', function(ev) {
const divPicker = document.querySelector('.emoji-picker__wrapper')
divPicker.style.top = '0'
divPicker.style.left = '0'

divPicker.addEventListener('keydown', function(ev) {
if (ev.keyCode === 27) { if (ev.keyCode === 27) {
ev.stopPropagation() ev.stopPropagation()
Shiny.setInputValue('close', Date.now()) Shiny.setInputValue('close', Date.now())

Загрузка…
Отмена
Сохранить