Sha256: 29ec592ba2cfdc0923a61fe11d5b44c52ae4766287d0f8358b51da2ec9c4d9b5

Contents?: true

Size: 1.56 KB

Versions: 35

Compression:

Stored size: 1.56 KB

Contents

import React from 'react'
import defaultColors from "../../tokens/exports/_colors.scss";
import { OverlayChildrenProps } from '../_overlay';


const previousOverlayDirectionMap: { [key: string]: string } = {
    "bottom": "to top",
    "top": "to bottom",
    "left": "to right",
    "right": "to left",
    "x": "to right",
    "y": "to top",
}

const subsequentOverlayDirectionMap: { [key: string]: string } = {
    ...previousOverlayDirectionMap,
    "x": "to left",
    "y": "to bottom",
}

const OverlayPercentage = (props: OverlayChildrenProps) => {
    const {
        children,
        color,
        position,
        size,
    } = props

    const getPreviousOverlayDirection = () => {
        return previousOverlayDirectionMap[position]
    }

    const getSubsequentOverlayDirection = () => {
        return subsequentOverlayDirectionMap[position]
    }

    const hasSubsequentOverlay = position === "x" || position === "y"

    const previousOverlay = `linear-gradient(${getPreviousOverlayDirection()}, ${defaultColors[color]} 0%, transparent ${size})`
    const subsequentOverlay = `linear-gradient(${getSubsequentOverlayDirection()}, ${defaultColors[color]} 0%, transparent ${size})`

    return (
        <>
            <div className="overlay_linear_gradient"
                style={{ background: previousOverlay }} />

            {children}

            { hasSubsequentOverlay &&
                <div className="overlay_linear_gradient"
                    style={{ background: subsequentOverlay }} />
            }       
        </>
    )
}

export default OverlayPercentage

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
playbook_ui-13.34.1.pre.alpha.play1407statvaluekitinconsistencies3388 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.1.pre.alpha.PLAY14703378 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.1 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3370 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3369 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3368 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.0.pre.alpha.PBNTR358responsiveadvancedtablereact3366 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.34.0 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.1.pre.alpha.play1407statvaluekitinconsistencies3352 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.1.pre.alpha.PLAY14063320 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.1 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.0.pre.alpha.PBNTR405dropdownformfixesrails3311 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.0.pre.alpha.PLAY1454formpillicons3309 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.33.0 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.32.0.pre.alpha.PBNTR405dropdownformfixesrails3301 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.32.0.pre.alpha.PLAY1138iconkitaddcolorprop3268 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.32.0.pre.alpha.play1416movealiaslogic3266 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.32.0.pre.alpha.play1416movealiaslogic3239 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.32.0.pre.alpha.PLAY14103236 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-13.31.0.pre.alpha.play1416movealiaslogic3232 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx