DocSpace-client/packages/components/infinite-loader/StyledInfiniteLoader.js

139 lines
3.3 KiB
JavaScript
Raw Normal View History

import { List } from "react-virtualized";
import styled, { css } from "styled-components";
import Base from "../themes/base";
2022-10-03 11:59:02 +00:00
import { mobile, tablet } from "../utils/device";
import { isMobile } from "react-device-detect";
const StyledScroll = styled.div`
overflow: scroll;
/* Chrome, Edge и Safari */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
background-color: ${({ theme }) => theme.scrollbar.backgroundColorVertical};
border-radius: 3px;
:hover {
background-color: ${({ theme }) =>
theme.scrollbar.hoverBackgroundColorVertical};
}
}
/* Firefox */
scrollbar-width: thin;
scrollbar-color: ${({ theme }) => theme.scrollbar.backgroundColorVertical};
`;
const rowStyles = css`
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-right: -20px;`
: `margin-left: -20px;`}
2022-10-03 11:59:02 +00:00
width: ${({ width }) => width + (isMobile ? 36 : 40) + "px !important"};
2022-09-08 08:48:06 +00:00
.ReactVirtualized__Grid__innerScrollContainer {
2022-10-03 11:59:02 +00:00
max-width: ${({ width }) => width + (isMobile ? 36 : 40) + "px !important"};
2022-09-30 10:19:50 +00:00
}
@media ${tablet} {
2022-09-30 11:47:15 +00:00
width: ${({ width }) => width + 36 + "px !important"};
.ReactVirtualized__Grid__innerScrollContainer {
max-width: ${({ width }) => width + 36 + "px !important"};
}
}
@media ${mobile} {
width: ${({ width }) => width + 28 + "px !important"};
2022-09-30 10:19:50 +00:00
.ReactVirtualized__Grid__innerScrollContainer {
2022-09-30 11:47:15 +00:00
max-width: ${({ width }) => width + 28 + "px !important"};
2022-09-30 10:19:50 +00:00
}
2022-09-08 08:48:06 +00:00
}
// !important styles override inline styles from react-virtualized
2022-09-07 12:05:30 +00:00
.row-list-item {
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `
padding-right: 16px;
left: unset !important;
right: 0 !important;
`
: `padding-left: 16px;`}
2022-09-30 11:57:43 +00:00
width: calc(100% - 32px) !important;
2022-09-08 08:48:06 +00:00
@media ${tablet} {
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `padding-right: 20px;`
: `padding-left: 20px;`}
2022-09-30 11:47:15 +00:00
width: calc(100% - 36px) !important;
2022-09-08 08:48:06 +00:00
}
@media ${mobile} {
2022-09-30 11:47:15 +00:00
width: calc(100% - 28px) !important;
}
}
`;
const tableStyles = css`
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-right: -20px;`
: `margin-left: -20px;`}
width: ${({ width }) => width + 40 + "px !important"};
.ReactVirtualized__Grid__innerScrollContainer {
max-width: ${({ width }) => width + 40 + "px !important"};
}
.table-container_body-loader {
width: calc(100% - 48px) !important;
}
// !important styles override inline styles from react-virtualized
.table-list-item,
.table-container_body-loader {
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `
padding-right: 20px;
left: unset !important;
right: 0 !important;
`
: `padding-left: 20px;`}
}
`;
const tileStyles = css`
.files_header {
padding-top: 11px;
}
`;
const StyledList = styled(List)`
outline: none;
2022-08-12 14:01:53 +00:00
overflow: hidden !important;
// Override inline direction from react-virtualized
direction: inherit !important;
${({ viewAs }) =>
viewAs === "row"
? rowStyles
: viewAs === "table"
? tableStyles
: tileStyles}
`;
StyledScroll.defaultProps = {
theme: Base,
};
export { StyledScroll, StyledList };