-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
213 additions
and
116 deletions.
There are no files selected for viewing
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...s/molecules/StickyTableOfContent/index.md → ...s/components/molecules/AnchorNav/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/docs/components/molecules/AnchorNav/stories/app.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% set section_length = 3 %} | ||
<style type="text/css"> | ||
.current { color: pink; } | ||
</style> | ||
|
||
|
||
<div data-component="AnchorNav" class="flex items-start relative"> | ||
<nav class="bg-blue-200 w-1/3 sticky flex flex-col top-4"> | ||
<ul> | ||
{% for item in 1..section_length %} | ||
<li> | ||
<a href="#item-{{ loop.index }}" | ||
data-component="AnchorNavLink" | ||
data-option-enter-to="text-purple-500" | ||
data-option-enter-active="transition-colors duration-300 ease-out-quad" | ||
data-option-leave-from="text-purple-500" | ||
data-option-leave-active="transition-colors duration-300 ease-out-quad" | ||
class="py-2 px-2"> | ||
item-{{ loop.index }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</nav> | ||
<div class="w-2/3" data-component="AnchorNavTarget"> | ||
<div data-ref="item[]" id="item-1" class="relative bg-purple-200 h-[300px]"> | ||
<div class="bg-pink-200 h-[50px]"> | ||
Item-1 | ||
</div> | ||
</div> | ||
<div data-ref="item[]" id="item-2" class="relative bg-purple-300 h-[300px]"> | ||
<div class="bg-pink-200 h-[50px]"> | ||
Item-2 | ||
</div> | ||
</div> | ||
<div data-ref="item[]" id="item-3" class="relative bg-purple-400 h-[300px]"> | ||
<div class="bg-pink-200 h-[50px]"> | ||
Item-3 | ||
</div> | ||
</div> | ||
{# {% for item in 1..section_length %} | ||
<section data-component="AnchorNavTarget" | ||
id="item-{{ loop.index }}" | ||
class="relative bg-purple-200 h-[300px]"> | ||
<div class="bg-pink-200 h-[50px]"> | ||
Item-{{ loop.index }} | ||
</div> | ||
</section> | ||
{% endfor %} #} | ||
</div> | ||
</div> | ||
|
||
<div class="h-screen"></div> |
32 changes: 0 additions & 32 deletions
32
packages/docs/components/molecules/StickyTableOfContent/stories/app.twig
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Base } from '@studiometa/js-toolkit'; | ||
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit'; | ||
import { AnchorNavLink } from './AnchorNavLink.js'; | ||
import { AnchorNavTarget } from './AnchorNavTarget.js'; | ||
|
||
export interface AnchorNavProps extends BaseProps { | ||
$children: { | ||
AnchorNavLink: AnchorNavLink[]; | ||
AnchorNavTarget: AnchorNavTarget[]; | ||
}; | ||
} | ||
|
||
export class AnchorNav<T extends BaseProps = BaseProps> extends Base<T & AnchorNavProps> { | ||
/** | ||
* Config | ||
*/ | ||
static config: BaseConfig = { | ||
name: 'AnchorNav', | ||
components: { | ||
AnchorNavLink, | ||
AnchorNavTarget, | ||
}, | ||
}; | ||
|
||
/** | ||
* Listen to the AnchorNavTarget that is intersected | ||
*/ | ||
onAnchorNavTargetIsIntersected(id) { | ||
console.log(id); | ||
|
||
if (document.querySelector('.current')) { | ||
document.querySelector('.current').classList.remove('current'); | ||
} | ||
const currentAnchorNavLink = this.$children.AnchorNavLink.find( | ||
(anchorNavLink) => anchorNavLink.targetSelector === id, | ||
); | ||
currentAnchorNavLink.$el.classList.add('current'); | ||
} | ||
|
||
// this.$children.AnchorNavLink.filter((navLink, navLinkId) => id !== navLinkId).forEach( | ||
// ({ leave }) => leave(), | ||
// ); | ||
|
||
// this.$children.AnchorNavLink[id].enter(); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import type { BaseConfig } from '@studiometa/js-toolkit'; | ||
import { AnchorScrollTo } from '../../atoms/AnchorScrollTo/AnchorScrollTo.js'; | ||
|
||
export interface AnchorNavLinkProps extends AnchorScrollToProps { | ||
$options: { | ||
id: string; | ||
}; | ||
} | ||
|
||
/** | ||
* Manage a slider item and its state transition. | ||
*/ | ||
export class AnchorNavLink extends AnchorScrollTo<AnchorNavLinkProps> { | ||
/** | ||
* Config. | ||
*/ | ||
static config: BaseConfig = { | ||
...AnchorScrollTo.config, | ||
name: 'AnchorNavLink', | ||
}; | ||
} | ||
|
||
// import type { BaseConfig } from '@studiometa/js-toolkit'; | ||
// import { AnchorScrollTo, AnchorScrollToProps } from '../../atoms/AnchorScrollTo/AnchorScrollTo.js'; | ||
// import { withTransition } from '../../decorators/index.js'; | ||
// import { Transition } from '../../primitives/index.js'; | ||
|
||
// export interface AnchorNavLinkProps extends AnchorScrollToProps { | ||
// $options: { | ||
// id: string; | ||
// }; | ||
// } | ||
|
||
// /** | ||
// * Manage a slider item and its state transition. | ||
// */ | ||
// export class AnchorNavLink extends withTransition(AnchorScrollTo)<AnchorNavLinkProps> { | ||
// /** | ||
// * Config. | ||
// */ | ||
// static config: BaseConfig = { | ||
// ...AnchorScrollTo.config, | ||
// name: 'AnchorNavLink', | ||
// options: { | ||
// ...AnchorScrollTo.config.options, | ||
// ...Transition.config.options, | ||
// enterKeep: { | ||
// type: Boolean, | ||
// default: true, | ||
// }, | ||
// leaveKeep: { | ||
// type: Boolean, | ||
// default: true, | ||
// }, | ||
// }, | ||
// }; | ||
|
||
// enter() { | ||
// this.$options.active = true; | ||
// super.enter(); | ||
// } | ||
|
||
// leave() { | ||
// this.$options.active = false; | ||
// super.leave(); | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './AnchorNav.js'; | ||
export * from './AnchorNavLink.js'; | ||
export * from './AnchorNavTarget.js'; |
2 changes: 1 addition & 1 deletion
2
...ges/ui/molecules/StickyTable/package.json → packages/ui/molecules/AnchorNav/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@studiometa/ui-sticky-table", | ||
"name": "@studiometa/ui-anchor-nav", | ||
"type": "module", | ||
"version": "0.0.0" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.