diff --git a/web/src/index.js b/web/src/index.js index 4e33cbe9ba2c1c7386451a7b181eab568028cba3..50500db24ef3b5430228421a4247e297ddef6a73 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -19,6 +19,7 @@ import {SearchBox} from "./search-box.js" import {giphyIsEnabled, GiphySearchTab, setGiphyAPIKey} from "./giphy.js" import * as widgetAPI from "./widget-api.js" import * as frequent from "./frequently-used.js" +import * as userSettings from "./user-settings.js" // The base URL for fetching packs. The app will first fetch ${PACK_BASE_URL}/index.json, // then ${PACK_BASE_URL}/${packFile} for each packFile in the packs object of the index.json file. @@ -80,6 +81,9 @@ class App extends Component { stickersPerRow: parseInt(localStorage.mauStickersPerRow || "4"), theme: localStorage.mauStickerThemeOverride || this.defaultTheme, frequentlyUsed: makeFrequentlyUsedState(), + userSettings: { + hideGifIndicator: userSettings.shouldHideGifIndicator(), + }, } if (!supportedThemes.includes(this.state.theme)) { @@ -173,6 +177,18 @@ class App extends Component { } } + setDisplayGifIndicator(checked) { + userSettings.setShouldHideGifIndicator(checked) + this.setState({ + userSettings: { + ...this.state.userSettings, + hideGifIndicator: checked, + }, + }) + } + + // End settings + reloadPacks() { this.imageObserver.disconnect() this.sectionObserver.disconnect() @@ -371,7 +387,12 @@ class App extends Component { /> <div class="pack-list ${isMobileSafari ? "ios-safari-hack" : ""}" ref=${(elem) => (this.packListRef = elem)}> ${noPacksForSearch ? html`<div class="search-empty"><h1>No stickers match your search</h1></div>` : null} - ${packs.map((pack) => html`<${Pack} id=${pack.id} pack=${pack} send=${this.sendSticker}/>`)} + ${packs.map(pack => html`<${Pack} + id=${pack.id} + pack=${pack} + send=${this.sendSticker} + hideGifIndicator=${this.state.userSettings.hideGifIndicator} + />`)} <${Settings} app=${this}/> </div> `} @@ -400,6 +421,15 @@ const Settings = ({app}) => html` <option value="black">Black</option> </select> </div> + <div> + <label for="hide-gif-indicator">Hide GIF indicator:</label> + <input + type="checkbox" + id="hide-gif-indicator" + checked=${app.state.userSettings.hideGifIndicator} + onChange=${evt => app.setDisplayGifIndicator(evt.target.checked)} + /> + </div> </div> </section> ` @@ -428,20 +458,23 @@ const NavBarItem = ({pack, iconOverride = null, onClickOverride = null, extraCla </a> ` -const Pack = ({pack, send}) => html` +const Pack = ({ pack, send, hideGifIndicator }) => html` <section class="stickerpack" id="pack-${pack.id}" data-pack-id=${pack.id}> <h1>${pack.title}</h1> <div class="sticker-list"> ${pack.stickers.map(sticker => html` - <${Sticker} key=${sticker.id} sticker=${sticker} send=${send}/> + <${Sticker} key=${sticker.id} sticker=${sticker} send=${send} hideGifIndicator=${hideGifIndicator} /> `)} </div> </section> ` -const Sticker = ({ sticker, send }) => html` +const gifIcon = html`<div class="gif-indicator">GIF</div>` + +const Sticker = ({ sticker, send, hideGifIndicator }) => html` <div class="sticker" onClick=${() => send(sticker)}> <img data-src=${makeThumbnailURL(sticker)} alt=${sticker.body} title=${sticker.body} /> + ${sticker.info["mimetype"] === "image/gif" && !hideGifIndicator ? gifIcon : ''} </div> ` diff --git a/web/src/user-settings.js b/web/src/user-settings.js new file mode 100644 index 0000000000000000000000000000000000000000..881b47ba6ef4d24e0b405438e0ae314c0e3c7b2e --- /dev/null +++ b/web/src/user-settings.js @@ -0,0 +1,11 @@ +const SETTINGS_KEYS = { + gifIndicator: "mauHideGifIndicator", +}; + +export function shouldHideGifIndicator() { + return localStorage[SETTINGS_KEYS.gifIndicator] === "true"; +} + +export function setShouldHideGifIndicator(checked) { + localStorage[SETTINGS_KEYS.gifIndicator] = checked; +} diff --git a/web/style/index.css b/web/style/index.css index 1f2ec32e431060cd915e4a767b5a176e0f92fa90..dccd90412f17ed141c088746906da562eb819806 100644 --- a/web/style/index.css +++ b/web/style/index.css @@ -1 +1 @@ -*{font-family:sans-serif}body{margin:0}h1{font-size:1rem}:root{--stickers-per-row: 4;--sticker-size: calc(100vw / var(--stickers-per-row))}main{color:var(--text-color)}main.spinner{margin-top:5rem}main.error,main.empty{margin:2rem}main.empty{text-align:center}main.has-content{position:fixed;top:0;left:0;right:0;bottom:0;display:grid;grid-template-rows:calc(12vw + 2px) min-content auto}main.theme-light{--highlight-color: #eee;--search-box-color: var(--highlight-color);--text-color: black;background-color:#fff}main.theme-dark{--highlight-color: #444;--search-box-color: #383e4b;--text-color: white;background-color:#22262e}main.theme-dark .icon.icon-giphy{background-image:url(../res/giphy-dark.svg)}main.theme-black{--highlight-color: #222;--search-box-color: var(--highlight-color);--text-color: white;background-color:#000}main.theme-black .icon.icon-giphy{background-image:url(../res/giphy-dark.svg)}div.powered-by-giphy{padding:1rem}div.powered-by-giphy>img{width:100%}.icon{width:100%;height:100%;background-color:var(--text-color);mask-size:contain;-webkit-mask-size:contain;mask-image:var(--icon-image);-webkit-mask-image:var(--icon-image)}.icon.icon-settings{--icon-image: url(../res/settings.svg)}.icon.icon-recent{--icon-image: url(../res/recent.svg)}.icon.icon-search{--icon-image: url(../res/search.svg)}.icon.icon.icon-giphy{background:center/contain no-repeat url(../res/giphy-light.svg);mask:unset}.icon.icon-reset{--icon-image: url(../res/reset.svg)}nav{display:flex;overflow-x:auto}nav>a{border-bottom:2px solid transparent}nav>a.visible{border-bottom-color:green}nav>a>div.sticker{width:12vw;height:12vw}div.pack-list,nav{scrollbar-width:none}div.pack-list::-webkit-scrollbar,nav::-webkit-scrollbar{display:none}div.pack-list{overflow-y:auto}div.pack-list.ios-safari-hack{position:fixed;top:calc(calc(12vw + 2px) + calc(2 * 0.7rem + 2 * 0.5rem + 1rem));bottom:0;left:0;right:0;-webkit-overflow-scrolling:touch}div.search-empty{margin:1.2rem;text-align:center}section.stickerpack{margin-top:.75rem}section.stickerpack>div.sticker-list{display:flex;flex-wrap:wrap}section.stickerpack>h1{margin:0 0 0 .75rem}section.stickerpack#pack-giphy{display:flex;justify-content:space-between;flex-direction:column;min-height:100%}div.sticker{display:flex;padding:4px;cursor:pointer;position:relative;width:var(--sticker-size);height:var(--sticker-size);box-sizing:border-box}div.sticker:hover{background-color:var(--highlight-color)}div.sticker>img{display:none;width:100%;object-fit:contain}div.sticker>img.visible{display:initial}div.sticker>.icon{width:70%;height:70%;margin:15%}div.search-box{display:flex;margin:.5rem;padding:0;border-radius:.4rem;background-color:var(--search-box-color);opacity:.5;transition:all .1s;border:1px solid transparent}div.search-box input,div.search-box .icon-display{color:var(--text-color);outline:none;border:none;height:1rem;margin:0;padding:.7rem;background-color:transparent;-webkit-tap-highlight-color:transparent}div.search-box .icon-display{width:1rem}div.search-box .icon-display.reset-click-zone{cursor:pointer}div.search-box .icon-display .icon{display:block;width:1rem;height:1rem}div.search-box .icon-display .icon-search{opacity:.5}div.search-box input{flex-grow:1;font-size:1rem}div.settings-list{display:flex;flex-direction:column}div.settings-list>*{margin:.5rem}div.settings-list button{padding:.5rem;border-radius:.25rem}div.settings-list input:not([type=checkbox]){width:100%} +*{font-family:sans-serif}body{margin:0}h1{font-size:1rem}:root{--stickers-per-row: 4;--sticker-size: calc(100vw / var(--stickers-per-row))}main{color:var(--text-color)}main.spinner{margin-top:5rem}main.error,main.empty{margin:2rem}main.empty{text-align:center}main.has-content{position:fixed;top:0;left:0;right:0;bottom:0;display:grid;grid-template-rows:calc(12vw + 2px) min-content auto}main.theme-light{--highlight-color: #eee;--search-box-color: var(--highlight-color);--text-color: black;background-color:#fff}main.theme-dark{--highlight-color: #444;--search-box-color: #383e4b;--text-color: white;background-color:#22262e}main.theme-dark .icon.icon-giphy{background-image:url(../res/giphy-dark.svg)}main.theme-black{--highlight-color: #222;--search-box-color: var(--highlight-color);--text-color: white;background-color:#000}main.theme-black .icon.icon-giphy{background-image:url(../res/giphy-dark.svg)}div.powered-by-giphy{padding:1rem}div.powered-by-giphy>img{width:100%}.icon{width:100%;height:100%;background-color:var(--text-color);mask-size:contain;-webkit-mask-size:contain;mask-image:var(--icon-image);-webkit-mask-image:var(--icon-image)}.icon.icon-settings{--icon-image: url(../res/settings.svg)}.icon.icon-recent{--icon-image: url(../res/recent.svg)}.icon.icon-search{--icon-image: url(../res/search.svg)}.icon.icon.icon-giphy{background:center/contain no-repeat url(../res/giphy-light.svg);mask:unset}.icon.icon-reset{--icon-image: url(../res/reset.svg)}nav{display:flex;overflow-x:auto}nav>a{border-bottom:2px solid transparent}nav>a.visible{border-bottom-color:green}nav>a>div.sticker{width:12vw;height:12vw}div.pack-list,nav{scrollbar-width:none}div.pack-list::-webkit-scrollbar,nav::-webkit-scrollbar{display:none}div.pack-list{overflow-y:auto}div.pack-list.ios-safari-hack{position:fixed;top:calc(calc(12vw + 2px) + calc(2 * 0.7rem + 2 * 0.5rem + 1rem));bottom:0;left:0;right:0;-webkit-overflow-scrolling:touch}div.search-empty{margin:1.2rem;text-align:center}section.stickerpack{margin-top:.75rem}section.stickerpack>div.sticker-list{display:flex;flex-wrap:wrap}section.stickerpack>h1{margin:0 0 0 .75rem}section.stickerpack#pack-giphy{display:flex;justify-content:space-between;flex-direction:column;min-height:100%}div.sticker{display:flex;padding:4px;cursor:pointer;position:relative;width:var(--sticker-size);height:var(--sticker-size);box-sizing:border-box}div.sticker:hover{background-color:var(--highlight-color)}div.sticker>img{display:none;width:100%;object-fit:contain}div.sticker>img.visible{display:initial}div.sticker>.icon{width:70%;height:70%;margin:15%}div.search-box{display:flex;margin:.5rem;padding:0;border-radius:.4rem;background-color:var(--search-box-color);opacity:.5;transition:all .1s;border:1px solid transparent}div.search-box input,div.search-box .icon-display{color:var(--text-color);outline:none;border:none;height:1rem;margin:0;padding:.7rem;background-color:transparent;-webkit-tap-highlight-color:transparent}div.search-box .icon-display{width:1rem}div.search-box .icon-display.reset-click-zone{cursor:pointer}div.search-box .icon-display .icon{display:block;width:1rem;height:1rem}div.search-box .icon-display .icon-search{opacity:.5}div.search-box input{flex-grow:1;font-size:1rem}div.settings-list{display:flex;flex-direction:column}div.settings-list>*{margin:.5rem}div.settings-list button{padding:.5rem;border-radius:.25rem}div.settings-list input:not([type=checkbox]){width:100%}.gif-indicator{position:absolute;top:10px;left:10px;background-color:var(--highlight-color);color:var(--text-color);padding:5px;border-radius:3px;opacity:.7} diff --git a/web/style/index.sass b/web/style/index.sass index 167929bfe8de10f3c6fd1d3ca9ce96159c46c621..48d7ad3719a16b27063be9984feef6d93cc96caf 100644 --- a/web/style/index.sass +++ b/web/style/index.sass @@ -240,3 +240,13 @@ div.settings-list input:not([type="checkbox"]) width: 100% + +.gif-indicator + position: absolute + top: 10px + left: 10px + background-color: var(--highlight-color) + color: var(--text-color) + padding: 5px + border-radius: 3px + opacity: 0.7