diff --git a/packages/eds-core-react/src/components/Slider/Output.tsx b/packages/eds-core-react/src/components/Slider/Output.tsx index 485101d0c0..fafe86593b 100644 --- a/packages/eds-core-react/src/components/Slider/Output.tsx +++ b/packages/eds-core-react/src/components/Slider/Output.tsx @@ -9,18 +9,23 @@ import { typographyTemplate } from '@equinor/eds-utils' import { slider as tokens } from './Slider.tokens' const { - entities: { track, output }, + entities: { output }, } = tokens const StyledOutput = styled.output` --realWidth: calc(100% - 12px); + --background: rgb(0 0 0 / 0.8); width: fit-content; position: relative; + display: flex; + align-items: center; + border-radius: 4px; z-index: 1; - ${typographyTemplate(output.typography)} - background: ${tokens.background}; - padding: 0 5px; - top: ${track.spacings.top}; + ${typographyTemplate(output.typography)}; + color: white; + background: var(--background); + padding: 8px; + top: -32px; pointer-events: none; /* Calculate the distance on the track*/ margin-left: calc((var(--val) - var(--min)) / var(--dif) * var(--realWidth)); @@ -28,6 +33,18 @@ const StyledOutput = styled.output` transform: translate(calc(-1 * calc(var(--realWidth) / 2))); grid-row: 2; grid-column: 1 / -1; + opacity: var(--showTooltip); +` + +const TooltipArrow = styled.svg` + width: 6px; + height: 8px; + position: absolute; + fill: var(--background); + top: calc(100% - 1px); + rotate: -90deg; + translate: -50%; + left: 50%; ` type OutputProps = { @@ -48,6 +65,9 @@ export const Output = forwardRef( htmlFor={htmlFor} > {children} + + + ) }, diff --git a/packages/eds-core-react/src/components/Slider/Slider.docs.mdx b/packages/eds-core-react/src/components/Slider/Slider.docs.mdx index a386dd3db3..3b8c0efb3d 100644 --- a/packages/eds-core-react/src/components/Slider/Slider.docs.mdx +++ b/packages/eds-core-react/src/components/Slider/Slider.docs.mdx @@ -39,6 +39,10 @@ import { Slider } from '@equinor/eds-core-react' +### Label always visible + + + ### Simple slider with steps diff --git a/packages/eds-core-react/src/components/Slider/Slider.stories.tsx b/packages/eds-core-react/src/components/Slider/Slider.stories.tsx index 088bab0520..da28253aba 100644 --- a/packages/eds-core-react/src/components/Slider/Slider.stories.tsx +++ b/packages/eds-core-react/src/components/Slider/Slider.stories.tsx @@ -48,6 +48,16 @@ export const SimpleSlider: StoryFn = () => ( ) SimpleSlider.storyName = 'Simple slider' +export const LabelAlwaysOn: StoryFn = () => ( + +) + export const SimpleSliderWithSteps: StoryFn = () => ( <>