Skip to content

Instantly share code, notes, and snippets.

const supportedScreenOrientation =
(screen?.orientation || {}).type ?? (screen as any).mozOrientation ?? (screen as any).msOrientation
const safariScreenOrientation: OrientationType =
!screen?.orientation && matchMedia('(orientation: portrait)').matches ? 'portrait-primary' : 'landscape-primary'
const initialScreenOrientation = supportedScreenOrientation ?? safariScreenOrientation ?? 'portrait-primary'
let screenOrientation: OrientationType = initialScreenOrientation
if (screen.orientation) {
enum MobileOS {
Android = 'android',
iOS = 'ios',
Unknown = 'unknown',
WindowsPhone = 'Windows Phone'
}
/**
* https://stackoverflow.com/a/21742107
* Determine the mobile operating system.
export interface DeviceState {
isDesktop: boolean
desktopOS: DesktopOS | undefined
isWindowsDesktop: boolean
isLinuxOrUnixDesktop: boolean
isMobile: boolean
mobileOS: MobileOS | undefined
isAndroidDevice: boolean
isAppleDevice: boolean
const userAgent: string = navigator.userAgent || navigator.vendor || window.opera
const isMobileDevice = (): boolean => {
const regexs = [/(Android)(.+)(Mobile)/i, /BlackBerry/i, /iPhone|iPod/i, /Opera Mini/i, /IEMobile/i]
return regexs.some((b) => userAgent.match(b))
}
const isTabletDevice = (): boolean => {
const regex = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/
return regex.test(userAgent.toLowerCase())
@AvocadoVenom
AvocadoVenom / ExpandableBlockContent.vue
Last active June 25, 2022 11:00
Autonomous expandable block content which detects toggle button need
<template>
<div class="block-content">
<transition
@before-enter="onBeforeEnter"
@enter="onEnter"
@after-enter="onAfterEnter"
@before-leave="onBeforeLeave"
@leave="onLeave"
mode="out-in"
>
@AvocadoVenom
AvocadoVenom / ExpandableBlockContent.vue
Created June 19, 2022 20:58
Expandable block content with smooth read less/read more feature
<template>
<div class="block-content">
<transition
@before-enter="onBeforeEnter"
@enter="onEnter"
@after-enter="onAfterEnter"
@before-leave="onBeforeLeave"
@leave="onLeave"
mode="out-in"
>
@AvocadoVenom
AvocadoVenom / ExpandableBlockContent.vue
Last active June 19, 2022 20:09
Expandable block content component with smooth transition
<template>
<div class="block-content">
<button
type="button"
class="block-content__button"
aria-label="Toggle button"
@click="isExpanded = !isExpanded"
>
{{ toggleCtaLabel }}
</button>
<template>
<div class="block-content">
<button
type="button"
class="block-content__button"
aria-label="Toggle button"
@click="isExpanded = !isExpanded"
>
{{ toggleCtaLabel }}
</button>
{
// ...
"postversion": "git push --follow-tags && yarn run generate-changelog",
"generate-changelog": "node ./scripts/gitlab/gitlab-changelog.js"
}
stages:
# - ...
- tag
changelog:
stage: tag
image: curlimages/curl:7.79.1
only:
- dev # Feel free to update this condition
script: