Skip to content

Commit

Permalink
Feat: added story and fade transition
Browse files Browse the repository at this point in the history
  • Loading branch information
srijitcoder committed Jan 13, 2025
1 parent 6393743 commit 816c0a6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
16 changes: 16 additions & 0 deletions elements/storytelling/src/helpers/render-html-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export function renderHtmlString(htmlString, sections, initDispatchFunc, that) {
);
}

let currentSrc = "";

/**
* Assign new value for attribute of element
*
Expand All @@ -142,6 +144,20 @@ function assignNewAttrValue(section, index, elementSelector, parent) {
Object.keys(section.steps[index]).forEach((attr) => {
element[attr] = section.steps[index][attr];
});

if (
["IMG", "VIDEO"].includes(element.tagName) &&
element.src !== currentSrc
) {
const newSrc = element.src;
element.style.opacity = 0.5;
element.src = currentSrc || newSrc;
currentSrc = newSrc;
setTimeout(() => {
element.src = currentSrc;
element.style.opacity = 1;
}, 500);
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions elements/storytelling/src/style.eox.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ ${slider}
position: sticky;
top:0;
z-index: 0;
opacity: 1;
object-fit: cover;
transition: all 0.5s linear;
-webkit-transition: all 0.5s linear;
-moz-transition: all 0.5s linear;
-o-transition: all 0.5s linear;
}
.story-telling .tour section-step {
background: white;
Expand Down
1 change: 1 addition & 0 deletions elements/storytelling/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { default as MarkdownAsURLStory } from "./markdown-url"; // StoryTelling
export { default as MarkdownSlotStory } from "./markdown-slot"; // StoryTelling with markdown from the slot
export { default as MarkdownEditorStory } from "./markdown-editor"; // StoryTelling with editor
export { default as MarkdownInitEventStory } from "./markdown-init-event"; // StoryTelling with init event
export { default as MarkdownTourStory } from "./markdown-tour"; // StoryTelling with tour
31 changes: 31 additions & 0 deletions elements/storytelling/stories/markdown-tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Renders storytelling with tour.
*/
import { html } from "lit";

export const MarkdownTour = {
args: {
markdown: `## Map Tour section <!--{ as="img" mode="tour" }-->
### <!--{ src='https://www.gstatic.com/prettyearth/assets/full/14617.jpg' }-->
#### This is Image tour - one.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
### <!--{ src='https://www.gstatic.com/prettyearth/assets/full/12516.jpg' }-->
#### This is Image tour - two.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
### <!--{ src='https://www.gstatic.com/prettyearth/assets/full/5046.jpg' }-->
#### This is Image tour - three.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
`,
},
render: (args) => html`
<eox-storytelling
id="markdown-tour"
markdown=${args.markdown}
></eox-storytelling>
`,
};

export default MarkdownTour;
6 changes: 6 additions & 0 deletions elements/storytelling/stories/storytelling.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MarkdownSlotStory,
MarkdownEditorStory,
MarkdownInitEventStory,
MarkdownTourStory,
} from "./index";
import { html } from "lit";

Expand Down Expand Up @@ -52,3 +53,8 @@ export const MarkdownWithEditor = MarkdownEditorStory;
* StoryTelling with @init event
*/
export const MarkdownInitEvent = MarkdownInitEventStory;

/**
* StoryTelling with tour.
*/
export const MarkdownTour = MarkdownTourStory;

0 comments on commit 816c0a6

Please sign in to comment.