<commit_before>/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14367

.mx_RoomSublist2 {
    // The sublist is a column of rows, essentially
    display: flex;
    flex-direction: column;

    margin-left: 8px;
    margin-bottom: 4px;
    width: 100%;

    flex-shrink: 0; // to convince safari's layout engine the flexbox is fine

    .mx_RoomSublist2_headerContainer {
        // Create a flexbox to make alignment easy
        display: flex;
        align-items: center;

        // ***************************
        // Sticky Headers Start

        // Ideally we'd be able to use `position: sticky; top: 0; bottom: 0;` on the
        // headerContainer, however due to our layout concerns we actually have to
        // calculate it manually so we can sticky things in the right places. We also
        // target the headerText instead of the container to reduce jumps when scrolling,
        // and to help hide the badges/other buttons that could appear on hover. This
        // all works by ensuring the header text has a fixed height when sticky so the
        // fixed height of the container can maintain the scroll position.

        // The combined height must be set in the LeftPanel2 component for sticky headers
        // to work correctly.
        padding-bottom: 8px;
        height: 24px;
        color: $roomlist2-header-color;

        .mx_RoomSublist2_stickable {
            flex: 1;
            max-width: 100%;

            // Create a flexbox to make ordering easy
            display: flex;
            align-items: center;

            // We use a generic sticky class for 2 reasons: to reduce style duplication and
            // to identify when a header is sticky. If we didn't have a consistent sticky class,
            // we'd have to do the "is sticky" checks again on click, as clicking the header
            // when sticky scrolls instead of collapses the list.
            &.mx_RoomSublist2_headerContainer_sticky {
                position: fixed;
                height: 32px; // to match the header container
                // width set by JS
                width: calc(100% - 22px);
            }

            &.mx_RoomSublist2_headerContainer_stickyBottom {
                bottom: 0;
            }

            // We don't have a top style because the top is dependent on the room list header's
            // height, and is therefore calculated in JS.
            // The class, mx_RoomSublist2_headerContainer_stickyTop, is applied though.
        }

        // Sticky Headers End
        // ***************************

        .mx_RoomSublist2_badgeContainer {
            // Create another flexbox row because it's super easy to position the badge this way.
            display: flex;
            align-items: center;
            justify-content: center;

            // Apply the width and margin to the badge so the container doesn't occupy dead space
            .mx_NotificationBadge {
                // Do not set a width so the badges get properly sized
                margin-left: 8px; // same as menu+aux buttons
            }
        }

        &:not(.mx_RoomSublist2_headerContainer_withAux) {
            .mx_NotificationBadge {
                margin-right: 4px; // just to push it over a bit, aligning it with the other elements
            }
        }

        .mx_RoomSublist2_auxButton,
        .mx_RoomSublist2_menuButton {
            margin-left: 8px; // should be the same as the notification badge
            position: relative;
            width: 24px;
            height: 24px;
            border-radius: 32px;

            &::before {
                content: '';
                width: 16px;
                height: 16px;
                position: absolute;
                top: 4px;
                left: 4px;
                mask-position: center;
                mask-size: contain;
                mask-repeat: no-repeat;
                background: $muted-fg-color;
            }
        }

        // Hide the menu button by default
        .mx_RoomSublist2_menuButton {
            visibility: hidden;
            width: 0;
            margin: 0;
        }

        .mx_RoomSublist2_auxButton::before {
            mask-image: url('$(res)/img/feather-customised/plus.svg');
        }

        .mx_RoomSublist2_menuButton::before {
            mask-image: url('$(res)/img/element-icons/context-menu.svg');
        }

        .mx_RoomSublist2_headerText {
            flex: 1;
            max-width: calc(100% - 16px); // 16px is the badge width
            line-height: $font-16px;
            font-size: $font-13px;
            font-weight: 600;

            // Ellipsize any text overflow
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;

            .mx_RoomSublist2_collapseBtn {
                display: inline-block;
                position: relative;
                width: 12px;
                height: 12px;
                margin-right: 8px;

                &::before {
                    content: '';
                    width: 12px;
                    height: 12px;
                    position: absolute;
                    top: 1px;
                    left: 1px;
                    mask-position: center;
                    mask-size: contain;
                    mask-repeat: no-repeat;
                    background-color: $primary-fg-color;
                    mask-image: url('$(res)/img/feather-customised/chevron-down.svg');
                }

                &.mx_RoomSublist2_collapseBtn_collapsed::before {
                    mask-image: url('$(res)/img/feather-customised/chevron-right.svg');
                }
            }
        }
    }

    // In the general case, we leave height of headers alone even if sticky, so
    // that the sublists below them do not jump. However, that leaves a gap
    // when scrolled to the top above the first sublist (whose header can only
    // ever stick to top), so we force height to 0 for only that first header.
    // See also https://github.com/vector-im/riot-web/issues/14429.
    &:first-child .mx_RoomSublist2_headerContainer {
        height: 0;
    }

    .mx_RoomSublist2_resizeBox {
        position: relative;

        // Create another flexbox column for the tiles
        display: flex;
        flex-direction: column;
        overflow: hidden;

        .mx_RoomSublist2_tiles {
            flex: 1 0 0;
            overflow: hidden;
            // need this to be flex otherwise the overflow hidden from above
            // sometimes vertically centers the clipped list ... no idea why it would do this
            // as the box model should be top aligned. Happens in both FF and Chromium
            display: flex;
            flex-direction: column;

            mask-image: linear-gradient(0deg, transparent, black 4px)
        }

        .mx_RoomSublist2_resizerHandles_showNButton {
            flex: 0 0 32px;
        }

        .mx_RoomSublist2_resizerHandles {
            flex: 0 0 4px;
        }

        // Class name comes from the ResizableBox component<commit_msg>bring back padding between show more and resize handle<commit_after>/*
Copyright 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14367

.mx_RoomSublist2 {
    // The sublist is a column of rows, essentially
    display: flex;
    flex-direction: column;

    margin-left: 8px;
    margin-bottom: 4px;
    width: 100%;

    flex-shrink: 0; // to convince safari's layout engine the flexbox is fine

    .mx_RoomSublist2_headerContainer {
        // Create a flexbox to make alignment easy
        display: flex;
        align-items: center;

        // ***************************
        // Sticky Headers Start

        // Ideally we'd be able to use `position: sticky; top: 0; bottom: 0;` on the
        // headerContainer, however due to our layout concerns we actually have to
        // calculate it manually so we can sticky things in the right places. We also
        // target the headerText instead of the container to reduce jumps when scrolling,
        // and to help hide the badges/other buttons that could appear on hover. This
        // all works by ensuring the header text has a fixed height when sticky so the
        // fixed height of the container can maintain the scroll position.

        // The combined height must be set in the LeftPanel2 component for sticky headers
        // to work correctly.
        padding-bottom: 8px;
        height: 24px;
        color: $roomlist2-header-color;

        .mx_RoomSublist2_stickable {
            flex: 1;
            max-width: 100%;

            // Create a flexbox to make ordering easy
            display: flex;
            align-items: center;

            // We use a generic sticky class for 2 reasons: to reduce style duplication and
            // to identify when a header is sticky. If we didn't have a consistent sticky class,
            // we'd have to do the "is sticky" checks again on click, as clicking the header
            // when sticky scrolls instead of collapses the list.
            &.mx_RoomSublist2_headerContainer_sticky {
                position: fixed;
                height: 32px; // to match the header container
                // width set by JS
                width: calc(100% - 22px);
            }

            &.mx_RoomSublist2_headerContainer_stickyBottom {
                bottom: 0;
            }

            // We don't have a top style because the top is dependent on the room list header's
            // height, and is therefore calculated in JS.
            // The class, mx_RoomSublist2_headerContainer_stickyTop, is applied though.
        }

        // Sticky Headers End
        // ***************************

        .mx_RoomSublist2_badgeContainer {
            // Create another flexbox row because it's super easy to position the badge this way.
            display: flex;
            align-items: center;
            justify-content: center;

            // Apply the width and margin to the badge so the container doesn't occupy dead space
            .mx_NotificationBadge {
                // Do not set a width so the badges get properly sized
                margin-left: 8px; // same as menu+aux buttons
            }
        }

        &:not(.mx_RoomSublist2_headerContainer_withAux) {
            .mx_NotificationBadge {
                margin-right: 4px; // just to push it over a bit, aligning it with the other elements
            }
        }

        .mx_RoomSublist2_auxButton,
        .mx_RoomSublist2_menuButton {
            margin-left: 8px; // should be the same as the notification badge
            position: relative;
            width: 24px;
            height: 24px;
            border-radius: 32px;

            &::before {
                content: '';
                width: 16px;
                height: 16px;
                position: absolute;
                top: 4px;
                left: 4px;
                mask-position: center;
                mask-size: contain;
                mask-repeat: no-repeat;
                background: $muted-fg-color;
            }
        }

        // Hide the menu button by default
        .mx_RoomSublist2_menuButton {
            visibility: hidden;
            width: 0;
            margin: 0;
        }

        .mx_RoomSublist2_auxButton::before {
            mask-image: url('$(res)/img/feather-customised/plus.svg');
        }

        .mx_RoomSublist2_menuButton::before {
            mask-image: url('$(res)/img/element-icons/context-menu.svg');
        }

        .mx_RoomSublist2_headerText {
            flex: 1;
            max-width: calc(100% - 16px); // 16px is the badge width
            line-height: $font-16px;
            font-size: $font-13px;
            font-weight: 600;

            // Ellipsize any text overflow
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;

            .mx_RoomSublist2_collapseBtn {
                display: inline-block;
                position: relative;
                width: 12px;
                height: 12px;
                margin-right: 8px;

                &::before {
                    content: '';
                    width: 12px;
                    height: 12px;
                    position: absolute;
                    top: 1px;
                    left: 1px;
                    mask-position: center;
                    mask-size: contain;
                    mask-repeat: no-repeat;
                    background-color: $primary-fg-color;
                    mask-image: url('$(res)/img/feather-customised/chevron-down.svg');
                }

                &.mx_RoomSublist2_collapseBtn_collapsed::before {
                    mask-image: url('$(res)/img/feather-customised/chevron-right.svg');
                }
            }
        }
    }

    // In the general case, we leave height of headers alone even if sticky, so
    // that the sublists below them do not jump. However, that leaves a gap
    // when scrolled to the top above the first sublist (whose header can only
    // ever stick to top), so we force height to 0 for only that first header.
    // See also https://github.com/vector-im/riot-web/issues/14429.
    &:first-child .mx_RoomSublist2_headerContainer {
        height: 0;
        padding-bottom: 4px;
    }

    .mx_RoomSublist2_resizeBox {
        position: relative;

        // Create another flexbox column for the tiles
        display: flex;
        flex-direction: column;
        overflow: hidden;

        .mx_RoomSublist2_tiles {
            flex: 1 0 0;
            overflow: hidden;
            // need this to be flex otherwise the overflow hidden from above
            // sometimes vertically centers the clipped list ... no idea why it would do this
            // as the box model should be top aligned. Happens in both FF and Chromium
            display: flex;
            flex-direction: column;

            mask-image: linear-gradient(0deg, transparent, black 4px)
        }

        .mx_RoomSublist2_resizerHandles_showNButton {
            flex: 0 0 32px;
        }

        .mx_RoomSublist2_resizerHandles {
            flex: 0 0 4px;
        }

        // Class name comes from the ResizableBox component
{'fraction_non_alphanumeric': 0.08097819073428829, 'fraction_numerical': 0.015808491418247517, 'mean_word_length': 1.6421752471871804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '657355', 'n_tokens_mistral': 4309, 'n_tokens_neox': 3935, 'n_words': 1425}