From cc33a697eb041be687941af35636ec0c081cb576 Mon Sep 17 00:00:00 2001 From: Jon McClure Date: Wed, 24 Aug 2022 21:13:50 +0100 Subject: [PATCH] PaddingReset --- src/components/BeforeAfter/BeforeAfter.svelte | 27 +++++----- .../FeaturePhoto/FeaturePhoto.svelte | 12 ++--- .../GraphicBlock/GraphicBlock.svelte | 10 ++-- .../PaddingReset/PaddingReset.stories.svelte | 52 +++++++++++++++++++ .../PaddingReset/PaddingReset.svelte | 23 ++++++++ src/components/PaddingReset/index.svelte | 18 ------- .../PaddingReset/stories/docs/component.md | 35 +++++++++++++ src/components/PhotoPack/PhotoPack.svelte | 4 +- src/index.js | 2 + 9 files changed, 138 insertions(+), 45 deletions(-) create mode 100644 src/components/PaddingReset/PaddingReset.stories.svelte create mode 100644 src/components/PaddingReset/PaddingReset.svelte delete mode 100644 src/components/PaddingReset/index.svelte create mode 100644 src/components/PaddingReset/stories/docs/component.md diff --git a/src/components/BeforeAfter/BeforeAfter.svelte b/src/components/BeforeAfter/BeforeAfter.svelte index 936ea92e..a4dec79e 100644 --- a/src/components/BeforeAfter/BeforeAfter.svelte +++ b/src/components/BeforeAfter/BeforeAfter.svelte @@ -3,6 +3,7 @@ import { onMount } from 'svelte'; import Block from '../Block/Block.svelte'; import type { ContainerWidth } from '../@types/global'; + import PaddingReset from '../PaddingReset/PaddingReset.svelte'; /** Width of the chart within the text well. */ export let width: ContainerWidth = 'normal'; // options: wide, wider, widest, fluid @@ -100,16 +101,16 @@ const move = (e) => { if (sliding && imgOffset) { const el = e.touches ? e.touches[0] : e; - const figureOffset = figure - ? parseInt(window.getComputedStyle(figure).marginLeft.slice(0, -2)) - : 0; + const figureOffset = figure ? + parseInt(window.getComputedStyle(figure).marginLeft.slice(0, -2)) : + 0; let x = el.pageX - figureOffset - imgOffset.left; x = - x < handleMargin - ? handleMargin - : x > w - handleMargin - ? w - handleMargin - : x; + x < handleMargin ? + handleMargin : + x > w - handleMargin ? + w - handleMargin : + x; offset = x / w; } }; @@ -220,10 +221,12 @@ {#if $$slots.caption} - + + + {/if} {/if} diff --git a/src/components/FeaturePhoto/FeaturePhoto.svelte b/src/components/FeaturePhoto/FeaturePhoto.svelte index b4bb51db..26cfa8be 100644 --- a/src/components/FeaturePhoto/FeaturePhoto.svelte +++ b/src/components/FeaturePhoto/FeaturePhoto.svelte @@ -2,6 +2,7 @@ import { onMount } from 'svelte'; import Block from '../Block/Block.svelte'; import type { ContainerWidth } from '../@types/global'; + import PaddingReset from '../PaddingReset/PaddingReset.svelte'; /** * Photo src @@ -72,7 +73,6 @@
{#if !lazy || (intersectable && intersecting)} {altText} @@ -80,7 +80,9 @@
{/if} {#if caption} -
{caption}
+ +
{caption}
+
{/if} {#if !altText}
altText
@@ -124,11 +126,5 @@ font-family: var(--theme-font-family-note, $font-family-display); color: var(--theme-colour-text-secondary, $tr-medium-grey); } - - &.fluid { - figcaption { - padding-left: 15px; - } - } } diff --git a/src/components/GraphicBlock/GraphicBlock.svelte b/src/components/GraphicBlock/GraphicBlock.svelte index fdf364fd..fdd60852 100644 --- a/src/components/GraphicBlock/GraphicBlock.svelte +++ b/src/components/GraphicBlock/GraphicBlock.svelte @@ -67,7 +67,7 @@ import AriaHidden from './AriaHidden.svelte'; import TextBlock from './TextBlock.svelte'; import Block from '../Block/Block.svelte'; - import PaddingReset from '../PaddingReset/index.svelte'; + import PaddingReset from '../PaddingReset/PaddingReset.svelte'; import { marked } from 'marked'; @@ -81,14 +81,14 @@ >
{#if $$slots.title} - + {:else if title} - +

{title}

{#if description} @@ -112,14 +112,14 @@
{/if} {#if $$slots.notes} - + {:else if notes} - +