diff --git a/.changeset/new-ants-decide.md b/.changeset/new-ants-decide.md new file mode 100644 index 0000000000..2aaef7b8c9 --- /dev/null +++ b/.changeset/new-ants-decide.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": minor +--- + +Fix image centering for widget diff --git a/packages/perseus/src/styles/widgets/image.less b/packages/perseus/src/styles/widgets/image.less index 020d61239c..5e0004489a 100644 --- a/packages/perseus/src/styles/widgets/image.less +++ b/packages/perseus/src/styles/widgets/image.less @@ -1,5 +1,6 @@ .perseus-image-widget { - margin: 0; + margin-left: auto; + margin-right: auto; .perseus-image-title { text-align: center; @@ -10,11 +11,6 @@ padding-left: 16px; position: relative; - // This offsets the paragraph's padding - // So that the caption sits much closer - // to the image - top: -12px; - &::before { content: ""; position: absolute; diff --git a/packages/perseus/src/widgets/__stories__/image.stories.tsx b/packages/perseus/src/widgets/__stories__/image.stories.tsx index e9a01c66b7..39d96116ed 100644 --- a/packages/perseus/src/widgets/__stories__/image.stories.tsx +++ b/packages/perseus/src/widgets/__stories__/image.stories.tsx @@ -72,6 +72,7 @@ export const Question2 = (args: StoryArgs): React.ReactElement => { imageOptions != null ? { ...imageOptions, + alignment: "full-width", title: args.title, caption: "There is neither happiness nor unhappiness in this world; there is only the comparison of one state with another. Only a man who has felt ultimate despair is capable of feeling ultimate bliss. It is necessary to have wished for death in order to know how good it is to live.....the sum of all human wisdom will be contained in these two words: Wait and Hope", diff --git a/packages/perseus/src/widgets/__tests__/__snapshots__/group.test.tsx.snap b/packages/perseus/src/widgets/__tests__/__snapshots__/group.test.tsx.snap index 6c3b2fbab5..f9487651b5 100644 --- a/packages/perseus/src/widgets/__tests__/__snapshots__/group.test.tsx.snap +++ b/packages/perseus/src/widgets/__tests__/__snapshots__/group.test.tsx.snap @@ -1146,6 +1146,7 @@ exports[`group widget should snapshot: initial render 1`] = ` >
{ } return ( -
+
{image} {alt} {titleAndCaption} @@ -260,7 +265,12 @@ class ImageWidget extends React.Component { } return ( -
+
{title} {image} {alt}