-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: Move IDE header to ADS/Templates #37406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
4fa2aca
8940eca
7df7ad0
8d78cf8
4077591
6556665
45c851e
2ec019b
f6b0c26
60cc915
54b3d3e
cf265ba
04b09c8
f66c3d9
e7e38bb
e28c56e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import React from "react"; | ||
| import { ListHeaderContainer, ListItemContainer } from "./styles"; | ||
| import { Text } from "../../Text"; | ||
| import { Flex } from "../../Flex"; | ||
|
|
||
| interface Props { | ||
| headerText: string; | ||
| headerControls?: React.ReactNode; | ||
| maxHeight?: string; | ||
| children: React.ReactNode[]; | ||
| } | ||
|
|
||
| export const ListWithHeader = (props: Props) => { | ||
| return ( | ||
| <Flex | ||
| flexDirection="column" | ||
| justifyContent="center" | ||
| maxHeight={props.maxHeight} | ||
| overflow="hidden" | ||
| > | ||
| <ListHeaderContainer className="pages"> | ||
| <Text kind="heading-xs">{props.headerText}</Text> | ||
| {props.headerControls} | ||
| </ListHeaderContainer> | ||
| <ListItemContainer> | ||
| <Flex | ||
| alignItems="center" | ||
| flex="1" | ||
| flexDirection="column" | ||
| overflow="auto" | ||
| px="spaces-2" | ||
| width="100%" | ||
| > | ||
| {props.children} | ||
| </Flex> | ||
| </ListItemContainer> | ||
| </Flex> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { ListItemContainer, ListHeaderContainer } from "./styles"; | ||
| export { ListWithHeader } from "./ListWithHeader"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import styled from "styled-components"; | ||
| import { Flex } from "../../Flex"; | ||
|
|
||
| export const ListItemContainer = styled(Flex)` | ||
| & .t--entity-item { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're probably just moving, but applying styling through hardcoded selectors to children is an anti-pattern. The way I see it - such styling should not exist in ADS.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is just a move. I have created this into EntityExplorer because this needs to be updated soon. These classes will soon be part of the EntityExplorer template itself. |
||
| grid-template-columns: 0 auto 1fr auto auto auto auto auto; | ||
| height: 32px; | ||
|
|
||
| & .t--entity-name { | ||
| padding-left: var(--ads-v2-spaces-3); | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export const ListHeaderContainer = styled.div` | ||
| padding: var(--ads-v2-spaces-3); | ||
| padding-right: var(--ads-v2-spaces-2); | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| height: 40px; | ||
|
ankitakinger marked this conversation as resolved.
|
||
|
|
||
| span { | ||
| line-height: 20px; | ||
| } | ||
| `; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import styled from "styled-components"; | ||
| import { PopoverContent } from "../../../Popover"; | ||
|
|
||
| export const SwitchTrigger = styled.div<{ active: boolean }>` | ||
| display: flex; | ||
| border-radius: var(--ads-v2-border-radius); | ||
| background-color: ${(props) => | ||
| props.active ? `var(--ads-v2-color-bg-subtle)` : "unset"}; | ||
| cursor: pointer; | ||
| padding: var(--ads-v2-spaces-2); | ||
|
|
||
| :hover { | ||
| background-color: var(--ads-v2-color-bg-subtle); | ||
| } | ||
| `; | ||
|
|
||
| export const ContentContainer = styled(PopoverContent)` | ||
| padding: 0; | ||
| padding-bottom: 0.25em; | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import React, { type ForwardedRef, useCallback } from "react"; | ||
| import { Flex } from "../../../Flex"; | ||
| import { Icon } from "../../../Icon"; | ||
| import { Popover, PopoverTrigger } from "../../../Popover"; | ||
| import { Text } from "../../../Text"; | ||
| import * as Styled from "./HeaderSwitcher.styles"; | ||
|
|
||
| interface Props { | ||
| prefix: string; | ||
| title?: string; | ||
| titleTestId: string; | ||
| active: boolean; | ||
| setActive: (active: boolean) => void; | ||
| onClick?: React.MouseEventHandler<HTMLDivElement>; | ||
| className?: string; | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| export const IDEHeaderSwitcher = React.forwardRef( | ||
| (props: Props, ref: ForwardedRef<HTMLDivElement>) => { | ||
| const { | ||
| active, | ||
| children, | ||
| className, | ||
| onClick, | ||
| prefix, | ||
| setActive, | ||
| title, | ||
| titleTestId, | ||
| ...rest | ||
| } = props; | ||
|
|
||
| const separator = title ? " /" : ""; | ||
|
|
||
| const closeSwitcher = useCallback(() => { | ||
| return setActive(false); | ||
| }, [setActive]); | ||
|
|
||
| return ( | ||
| <Popover onOpenChange={setActive} open={active}> | ||
| <PopoverTrigger> | ||
| <Styled.SwitchTrigger | ||
| active={active} | ||
| className={`flex align-center items-center justify-center ${className}`} | ||
| data-testid={titleTestId} | ||
| onClick={onClick} | ||
| ref={ref} | ||
| {...rest} | ||
| > | ||
| <Text | ||
| color="var(--ads-v2-colors-content-label-inactive-fg)" | ||
| kind="body-m" | ||
| > | ||
| {prefix + separator} | ||
| </Text> | ||
| <Flex | ||
| alignItems="center" | ||
| className={titleTestId} | ||
| data-active={active} | ||
| gap="spaces-1" | ||
| height="100%" | ||
| justifyContent="center" | ||
| paddingLeft="spaces-2" | ||
| > | ||
| <Text isBold kind="body-m"> | ||
| {title} | ||
| </Text> | ||
| <Icon | ||
| color={ | ||
| title | ||
| ? undefined | ||
| : "var(--ads-v2-colors-content-label-inactive-fg)" | ||
| } | ||
| name={active ? "arrow-up-s-line" : "arrow-down-s-line"} | ||
| size="md" | ||
| /> | ||
| </Flex> | ||
| </Styled.SwitchTrigger> | ||
| </PopoverTrigger> | ||
| <Styled.ContentContainer align="start" onEscapeKeyDown={closeSwitcher}> | ||
| {children} | ||
| </Styled.ContentContainer> | ||
| </Popover> | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| IDEHeaderSwitcher.displayName = "IDEHeaderSwitcher"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { IDEHeaderSwitcher } from "./IDEHeaderSwitcher"; | ||
|
ankitakinger marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const IDE_HEADER_HEIGHT = 40; | ||
| export const LOGO_WIDTH = 50; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Canvas, Meta } from "@storybook/blocks"; | ||
| import * as IDEHeaderStories from "./IDEHeader.stories"; | ||
|
|
||
| <Meta of={IDEHeaderStories} /> | ||
|
|
||
| # IDEHeader | ||
|
|
||
| IDEHeader sets the stage for the IDE experience. It is the topmost section of the IDE that contains the Appsmith logo, the app name, and the user profile. | ||
|
|
||
| <Canvas of={IDEHeaderStories.Default} /> | ||
|
|
||
| ## Anatomy | ||
|
|
||
| ### Left Section options | ||
|
|
||
| The local title | ||
|
|
||
| #### Header Title | ||
|
|
||
| A title that is specific to the app state. It is displayed on the left side of the header. | ||
|
|
||
| <Canvas of={IDEHeaderStories.WithHeaderTitle} /> | ||
|
|
||
| #### Header Dropdown | ||
|
|
||
| A dropdown that allows the user to switch between different pages. | ||
|
|
||
| <Canvas of={IDEHeaderStories.WithHeaderDropdown} /> |
Uh oh!
There was an error while loading. Please reload this page.