Dropdown: Calendar Custom Selected

The calendar element is shown when the "personnalisé" radio element is checked. The "d-none" toggles its visibility.
<div aria-labelledby="" class="sds-actionMenu dropdown-menu -filters">
    <div class="dropdown-header">Trier</div>
    <div class="d-flex">
        <button type="button" class="sds-actionMenu__item dropdown-item d-flex">
            <span class="sds-iconCircle -secondary10" aria-hidden="true">

                <span class="sds-icon sds-icon-arrowbottom"></span>

            </span>

            <span>A-Z</span>
        </button>
        <button type="button" class="sds-actionMenu__item dropdown-item d-flex">
            <span class="sds-iconCircle -secondary10" aria-hidden="true">

                <span class="sds-icon sds-icon-arrowtop"></span>

            </span>

            <span>Z-A</span>
        </button>
    </div>
    <div class="dropdown-divider"></div>
    <div class="dropdown-header d-flex justify-content-between">
        Filtrer
    </div>
    <div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="default"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="default">
                    Blank
                </label>

            </div>
        </div>
        <div class="dropdown-divider"></div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="prevweek"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="prevweek">
                    Semaine passée
                </label>

            </div>
        </div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="currweek"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="currweek">
                    Cette semaine
                </label>

            </div>
        </div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="nextweek"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="nextweek">
                    Semaine prochaine
                </label>

            </div>
        </div>
        <div class="dropdown-divider"></div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="prevmonth"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="prevmonth">
                    Mois passé
                </label>

            </div>
        </div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="currmonth"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="currmonth">
                    Ce mois-ci
                </label>

            </div>
        </div>
        <div class="dropdown-item">
            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="nextmonth"><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="nextmonth">
                    Mois prochain
                </label>

            </div>
        </div>
        <div class="dropdown-divider"></div>
        <div class="dropdown-item">

            <div class="sds-radio custom-control custom-radio">
                <input value="radio-value" type="radio" name="radio-name" class="sr-only custom-control-input " id="custom" checked><span class="sds-radioDot  sds-radio__shape" aria-hidden="true"></span>
                <label class="custom-control-label" for="custom">
                    Personnalisé
                </label>

            </div>

        </div>
        <div class="dropdown-item -isStatic">
            <div class="sds-input -hasIcon -calendar js-flatpickr">
                <input id="inputCalendar" class="sds-input form-control" type="text" placeholder="11/04/2023" value="">

                <div class="sds-input__iconRight">

                    <span class="sds-icon sds-icon-calendar"></span>

                </div>

            </div>
        </div>
    </div>
</div>
<div aria-labelledby="{{ parentID }}" class="{{ namespace }}actionMenu dropdown-menu{% for mod in modifiers %} {{ mod }}{% endfor %}{% for mod in classes %} {{ mod }}{% endfor %}">
	<div class="dropdown-header">Trier</div>
	<div class="d-flex">
		<button type="button" class="{{ namespace }}actionMenu__item dropdown-item d-flex">
			{% render "@icon-circle-regular--secondary-10",{icon: "icon-arrowbottom"},true %}
			<span>A-Z</span>
		</button>
		<button type="button" class="{{ namespace }}actionMenu__item dropdown-item d-flex">
			{% render "@icon-circle-regular--secondary-10",{icon: "icon-arrowtop"},true %}
			<span>Z-A</span>
		</button>
	</div>
	<div class="dropdown-divider"></div>
	<div class="dropdown-header d-flex justify-content-between">
		Filtrer
	</div>
	<div>
		<div class="dropdown-item">
			{% render "@radio",{text: "Blank"},true %}
		</div>
		<div class="dropdown-divider"></div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "prevweek",
				id: "prevweek",
				text: "Semaine passée"
			},true %}
		</div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "currweek",
				id: "currweek",
				text: "Cette semaine"
			},true %}
		</div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "nextweek",
				id: "nextweek",
				text: "Semaine prochaine"
			},true %}
		</div>
		<div class="dropdown-divider"></div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "prevmonth",
				id: "prevmonth",
				text: "Mois passé"
			},true %}
		</div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "currmonth",
				id: "currmonth",
				text: "Ce mois-ci"
			},true %}
		</div>
		<div class="dropdown-item">
			{% render "@radio",{
				labelFor: "nextmonth",
				id: "nextmonth",
				text: "Mois prochain"
			},true %}
		</div>
		<div class="dropdown-divider"></div>
		<div class="dropdown-item">
			{% if customSelected %}
				{% render "@radio",{
					labelFor: "custom",
					id: "custom",
					text: "Personnalisé",
					checked: true
				},true %}
			{% else %}
				{% render "@radio",{
					labelFor: "custom",
					id: "custom",
					text: "Personnalisé"
				},true %}
			{% endif %}
		</div>
		<div class="dropdown-item -isStatic{% if customSelected %}{% else %} d-none{% endif %}">
			{% render "@cpb-input--calendar" %}
		</div>
	</div>
</div>
  • Content:
    export default class CpbDropdown {
    
    	constructor() {
    		this.initDropdownHeadroom();
    		this.fixedTableHeaders();
    	}
    
    	initDropdownHeadroom () {
    
    		let stickyDropdownHeaders = document.querySelectorAll(".sds-actionMenu__scrollHeader[data-headroom]");
    
    		if (CSS && CSS.supports && CSS.supports("position", "sticky")) {
    			if(stickyDropdownHeaders) {
    
    				stickyDropdownHeaders.forEach(function(el) {
    
    					let scrollSortHeight = el.querySelector(".sds-actionMenu__scrollSort").clientHeight;
    
    					let hr = new Headroom(el.parentNode, {
    						// vertical offset in px before element is first unpinned
    						offset : scrollSortHeight,
    						// or you can specify offset individually for up/down scroll
    
    						// scroll tolerance in px before state changes
    						tolerance : 0,
    						// or you can specify tolerance individually for up/down scroll
    
    						// css classes to apply
    						classes : {
    							// when element is initialised
    							initial : "-headroom",
    							// when scrolling up
    							pinned : "-headroomPinned",
    							// when scrolling down
    							unpinned : "-headroomUnpinned",
    							// when above offset
    							top : "-headroomTop",
    							// when below offset
    							notTop : "-headroomNotTop",
    							// when at bottom of scroll area
    							bottom : "-headroomBottom",
    							// when not at bottom of scroll area
    							notBottom : "-headroomNotBottom",
    							// when frozen method has been called
    							frozen: "-headroomFrozen",
    
    						},
    
    						scroller: el.parentNode,
    
    						// callback when pinned, `this` is headroom object
    						onPin : function() {
    							el.style = "transform: translateY(0)";
    						},
    						// callback when unpinned, `this` is headroom object
    						onUnpin : function() {
    							el.style = "transform: translateY(-"+ scrollSortHeight +"px)";
    						},
    						// callback when above offset, `this` is headroom object
    						onTop : function() {
    						},
    						// callback when below offset, `this` is headroom object
    						onNotTop : function() {},
    						// callback when at bottom of page, `this` is headroom object
    						onBottom : function() {},
    						// callback when moving away from bottom of page, `this` is headroom object
    						onNotBottom : function() {}
    					});
    					hr.init();
    				})
    			}
    		} else {
    			console.log("no position: sticky; support");
    		}
    
    	}
    
    	fixedTableHeaders () {
    		let element = document.querySelector("thead");
    		let parentElement = element.parentElement;
    		window.addEventListener('scroll', () => {
    			console.log("heyho")
    			let coordinates = parentElement.getBoundingClientRect();
    			if (coordinates.y < 0) {
    				element.style.transform = 'translate3d(0, ' + 'calc(128px + ' + (-coordinates.y) + 'px), 0)';
    			} else {
    				element.style.transform = 'translate3d(0,0,0)';
    			}
    		})
    	}
    
    }
    
  • URL: /components/raw/cpb-dropdown/CpbDropdown.js
  • Filesystem Path: components/corporate-bridge/molecules/dropdown/CpbDropdown.js
  • Size: 2.8 KB
  • Content:
    /* variables specific to current element */
    
    $element-specific-variables: "";
    
    .#{$namespace}actionMenu {
    
    	/* Save root element context for easy access if nesting is needed */
    
    	$self: &;
    
    	/* properties of current element  + media queries */
    
    	/* Pseudo Elements */
    
    	&::before {
    	}
    
    	&::after {
    	}
    
    	/*
    	Include elements that are linked to the current element but have to reside at the root level of the stylesheet
    	(e.g: keyframes)
    	*/
    	@at-root {
    	}
    
    
    	/* children - write selector in full in comments in order to facilitate search */
    
    	// actionMenu__reorder
    	&__reorder  {
    
    		// follows same logic as parent
    
    		color: map-deep-get($token-color-brand-map, "secondary", "100");
    
    	}
    
    	&__scrollHeader {
    
    		position: sticky;
    		top: -$dropdown-padding-y;
    		z-index: z("low");
    		@include custom-prop-fallback("background-color","comp-dropdown-background-color");
    		margin-top: -$dropdown-padding-y;
    		padding-top: $dropdown-padding-y;
    		padding-bottom: $dropdown-divider-margin-y;
    		margin-bottom: $dropdown-divider-margin-y;
    
    		transition: transform 0.25s linear;
    
    		&::after {
    
    			content: "";
    			position: absolute;
    			bottom: 0;
    			left: $dropdown-item-padding-x;
    			right: $dropdown-item-padding-x;
    			@include nav-divider($dropdown-divider-bg, 0, true);
    
    		}
    
    
    	}
    
    	&__scrollSort {
    		padding-bottom: $dropdown-divider-margin-y;
    	}
    
    	&__scrollNoMarginTop {
    
    		margin-top: 0 !important;
    
    	}
    
    
    	/* modifiers */
    
    	// actionMenu -altStyle
    	&.-filters {
    
    		// follows same logic as base element
    
    		width: 320px;
    		overflow-y: auto;
    		overscroll-behavior: contain;
    
    
    	}
    	
    	&.-reorder {
    
    		width: 320px;
    
    	}
    
    	/* random parent element */
    	/* 
    	*
    	*   Syntax : .randomParentElt & {}
    	*
    	*/
    
    	/* Pseudo Classes */
    
    	&:hover {
    		@media (hover: hover) {
    
    		}
    	}
    
    	&:focus {
    	}
    
    	&:active {
    	}
    
    	&:focus,
    	&:active {
    	}
    
    }
  • URL: /components/raw/cpb-dropdown/_action-menu.scss
  • Filesystem Path: components/corporate-bridge/molecules/dropdown/_action-menu.scss
  • Size: 1.8 KB