Sha256: 269abf423166972ea899a0914ee737a6e38965197998c05f9cee63c910068948

Contents?: true

Size: 1.57 KB

Versions: 545

Compression:

Stored size: 1.57 KB

Contents

import React from 'react'
import defaultColors from "../../tokens/exports/_colors.module.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

545 entries across 545 versions & 1 rubygems

Version Path
playbook_ui-14.14.0.pre.rc.4 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1900progresspillwidth6122 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1754pbtagprogressradio6121 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.pbntr799collapsiblerowswithcustomclick6117 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.PLAY1873rails86115 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.14.0.pre.rc.3 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.PLAY1873rails86087 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.PBNTR5596084 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1851checkboxreacthook6083 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.14.0.pre.rc.2 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.14.0.pre.rc.1 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1753updatepbcontenttags6065 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1884progresspill6064 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1753updatepbcontenttags6060 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.PBNTR5596029 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.alpha.play1834depupdatesass6024 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.14.0.pre.rc.0 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.12.0.pre.alpha.PLAY1888initializeOncereactdatepickerslowdown5956 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx
playbook_ui-14.13.0.pre.rc.10 app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx