Skip to content
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

refactor(DropdownMenu): ♻️ Move styling to dropdownmenu.css #1946

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@layer fds.dropdownmenu {
.dropdown {
.fds-dropdown {
position: relative;
padding: var(--fds-spacing-2);
z-index: 1500;
Expand All @@ -10,22 +10,37 @@
background-color: var(--fds-semantic-background-default);
}

.dropdown.small {
.fds-dropdown--small {
min-width: 240px;
padding: var(--fds-spacing-2);
}

.dropdown.medium {
.fds-dropdown--medium {
min-width: 260px;
padding: var(--fds-spacing-3) var(--fds-spacing-2);
}

.dropdown.large {
.fds-dropdown--large {
min-width: 280px;
padding: var(--fds-spacing-4) var(--fds-spacing-2);
}

.dropdown > hr {
.fds-dropdown > hr {
border-color: var(--fds-semantic-border-divider-subtle) !important;
}

.fds-dropdown__item {
justify-content: start;
padding: 0 var(--fds-spacing-4);
}

.fds-dropdown__section {
margin: 0;
padding: 0;
list-style: none;
}

.fds-dropdown__heading {
padding: var(--fds-spacing-2) var(--fds-spacing-4);
}
}
1 change: 1 addition & 0 deletions packages/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
@import url('./card.css');
@import url('./link.css');
@import url('./fieldset.css');
@import url('./dropdownmenu.css');
@import url('./divider.css');
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {
FloatingFocusManager,
FloatingPortal,
} from '@floating-ui/react';
import cl from 'clsx';
import cl from 'clsx/lite';

import { useIsomorphicLayoutEffect } from '../../hooks';

import classes from './DropdownMenu.module.css';
import { DropdownMenuContext } from './DropdownMenu';

const GAP = 4;
Expand Down Expand Up @@ -106,7 +105,7 @@ export const DropdownMenuContent = forwardRef<
ref: floatingRef,
tabIndex: undefined,
})}
className={cl(classes.dropdown, classes[size], className)}
className={cl('fds-dropdown', `fds-dropdown${size}`, className)}
{...rest}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { forwardRef, useContext, useId } from 'react';
import type * as React from 'react';
import cl from 'clsx';

import { Paragraph } from '../../Typography';
import { DropdownMenuContext } from '../DropdownMenu';
import { Paragraph } from '../Typography';

import classes from './DropdownMenuGroup.module.css';
import { DropdownMenuContext } from './DropdownMenu';

export type DropdownMenuGroupProps = {
/**
Expand All @@ -30,7 +28,7 @@ export const DropdownMenuGroup = forwardRef<
{...(heading ? { 'aria-labelledby': headingId } : {})}
ref={ref}
role='group'
className={classes.section}
className={'fds-dropdown__section'}
{...rest}
>
{heading && (
Expand All @@ -40,7 +38,7 @@ export const DropdownMenuGroup = forwardRef<
>
<h2
id={headingId}
className={cl(classes.heading)}
className={'fds-dropdown__heading'}
>
{heading}
</h2>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { forwardRef, useContext } from 'react';

import type { ButtonProps } from '../../Button';
import { Button } from '../../Button';
import { DropdownMenuContext } from '../DropdownMenu';
import type { ButtonProps } from '../Button';
import { Button } from '../Button';

import classes from './DropdownMenuItem.module.css';
import { DropdownMenuContext } from './DropdownMenu';

export type DropdownMenuItemProps = Omit<
ButtonProps,
Expand All @@ -27,7 +26,7 @@ export const DropdownMenuItem = forwardRef<
variant='tertiary'
size={menu.size}
fullWidth
className={classes.item}
className='fds-dropdown__item'
role='menuitem'
{...rest}
>
Expand Down

This file was deleted.

8 changes: 4 additions & 4 deletions packages/react/src/components/DropdownMenu/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DropdownMenu as DropdownRoot } from './DropdownMenu';
import { DropdownMenuGroup } from './DropdownMenuGroup/DropdownMenuGroup';
import { DropdownMenuItem } from './DropdownMenuItem/DropdownMenuItem';
import { DropdownMenuGroup } from './DropdownMenuGroup';
import { DropdownMenuItem } from './DropdownMenuItem';
import { DropdownMenuTrigger } from './DropdownMenuTrigger';
import { DropdownMenuContent } from './DropdownMenuContent';

Expand All @@ -24,8 +24,8 @@ DropdownMenu.Item.displayName = 'DropdownMenu.Item';
DropdownMenu.Trigger.displayName = 'DropdownMenu.Trigger';

export type { DropdownMenuProps } from './DropdownMenu';
export type { DropdownMenuGroupProps } from './DropdownMenuGroup/DropdownMenuGroup';
export type { DropdownMenuItemProps } from './DropdownMenuItem/DropdownMenuItem';
export type { DropdownMenuGroupProps } from './DropdownMenuGroup';
export type { DropdownMenuItemProps } from './DropdownMenuItem';
export type { DropdownMenuContentProps } from './DropdownMenuContent';
export {
DropdownMenu,
Expand Down
Loading