diff --git a/bestax-mcp/data/components/Navbar.json b/bestax-mcp/data/components/Navbar.json index af9917942..408ef8d10 100644 --- a/bestax-mcp/data/components/Navbar.json +++ b/bestax-mcp/data/components/Navbar.json @@ -195,7 +195,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier for the brand.", + "description": "Renders `has-text-`, exactly like `textColor`. Bulma has no `.navbar-brand.is-` rule, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list.", "required": false, "inherited": false, "deprecated": false @@ -394,7 +394,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier for the burger.", + "description": "Renders `has-text-`, exactly like `textColor`. Bulma has no `.navbar-burger.is-` rule, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list.", "required": false, "inherited": false, "deprecated": false @@ -487,7 +487,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier for the menu.", + "description": "Renders `has-text-`, exactly like `textColor`. Bulma has no `.navbar-menu.is-` rule, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list.", "required": false, "inherited": false, "deprecated": false @@ -543,7 +543,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier.", + "description": "Renders `has-text-`, exactly like `textColor`. Bulma has no `is-` rule for this area, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list.", "required": false, "inherited": false, "deprecated": false @@ -590,7 +590,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier.", + "description": "Renders `has-text-`, exactly like `textColor`. Bulma has no `is-` rule for this area, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list.", "required": false, "inherited": false, "deprecated": false diff --git a/bulma-ui/src/components/Navbar.tsx b/bulma-ui/src/components/Navbar.tsx index edb8694b0..c6eb41ac3 100644 --- a/bulma-ui/src/components/Navbar.tsx +++ b/bulma-ui/src/components/Navbar.tsx @@ -125,7 +125,12 @@ export interface NavbarBrandProps className?: string; /** Text color for the brand. */ textColor?: (typeof validColors)[number] | 'inherit' | 'current'; - /** Bulma color modifier for the brand. */ + /** + * Renders `has-text-`, exactly like `textColor`. Bulma has no + * `.navbar-brand.is-` rule, so this is not a filled variant. + * `textColor` takes precedence when both are set, and is the one that + * reaches the full color list. + */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Brand content. */ children?: React.ReactNode; @@ -142,10 +147,11 @@ export const NavbarBrand: React.FC = ({ className, children, textColor, + color, ...props }) => { const { bulmaHelperClasses, rest } = useBulmaClasses({ - color: textColor, + color: textColor ?? color, ...props, }); @@ -276,7 +282,12 @@ export interface NavbarBurgerProps className?: string; /** Text color for the burger. */ textColor?: (typeof validColors)[number] | 'inherit' | 'current'; - /** Bulma color modifier for the burger. */ + /** + * Renders `has-text-`, exactly like `textColor`. Bulma has no + * `.navbar-burger.is-` rule, so this is not a filled variant. + * `textColor` takes precedence when both are set, and is the one that + * reaches the full color list. + */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Whether the burger is active. */ active?: boolean; @@ -303,8 +314,12 @@ export interface NavbarBurgerProps * @returns {JSX.Element} The rendered burger. */ export const NavbarBurger = forwardRef( - function NavbarBurger({ className, active, children, ...props }, ref) { + function NavbarBurger( + { className, active, textColor, color, children, ...props }, + ref + ) { const { bulmaHelperClasses, rest } = useBulmaClasses({ + color: textColor ?? color, ...props, }); @@ -349,7 +364,12 @@ export interface NavbarMenuProps className?: string; /** Text color for the menu. */ textColor?: (typeof validColors)[number] | 'inherit' | 'current'; - /** Bulma color modifier for the menu. */ + /** + * Renders `has-text-`, exactly like `textColor`. Bulma has no + * `.navbar-menu.is-` rule, so this is not a filled variant. + * `textColor` takes precedence when both are set, and is the one that + * reaches the full color list. + */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Whether the menu is active. */ active?: boolean; @@ -367,10 +387,13 @@ export interface NavbarMenuProps export const NavbarMenu: React.FC = ({ className, active, + textColor, + color, children, ...props }) => { const { bulmaHelperClasses, rest } = useBulmaClasses({ + color: textColor ?? color, ...props, }); @@ -401,7 +424,12 @@ export interface NavbarStartEndProps className?: string; /** Text color. */ textColor?: (typeof validColors)[number] | 'inherit' | 'current'; - /** Bulma color modifier. */ + /** + * Renders `has-text-`, exactly like `textColor`. Bulma has no + * `is-` rule for this area, so this is not a filled variant. + * `textColor` takes precedence when both are set, and is the one that + * reaches the full color list. + */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Content. */ children?: React.ReactNode; @@ -416,10 +444,13 @@ export interface NavbarStartEndProps */ export const NavbarStart: React.FC = ({ className, + textColor, + color, children, ...props }) => { const { bulmaHelperClasses, rest } = useBulmaClasses({ + color: textColor ?? color, ...props, }); return ( @@ -445,10 +476,13 @@ export const NavbarStart: React.FC = ({ */ export const NavbarEnd: React.FC = ({ className, + textColor, + color, children, ...props }) => { const { bulmaHelperClasses, rest } = useBulmaClasses({ + color: textColor ?? color, ...props, }); return ( diff --git a/bulma-ui/src/components/__tests__/Navbar.test.tsx b/bulma-ui/src/components/__tests__/Navbar.test.tsx index d71a0fad4..9dd893a1f 100644 --- a/bulma-ui/src/components/__tests__/Navbar.test.tsx +++ b/bulma-ui/src/components/__tests__/Navbar.test.tsx @@ -174,6 +174,36 @@ describe('Navbar.Brand', () => { ); expect(screen.getByTestId('brand')).toHaveClass('custom-brand'); }); + + it('applies textColor as a helper class and not as a DOM attribute', () => { + render( + + Brand + + ); + const brand = screen.getByTestId('brand'); + expect(brand).toHaveClass('has-text-primary'); + expect(brand).not.toHaveAttribute('textColor'); + }); + + it('renders color as a text color, with textColor taking precedence', () => { + const { rerender } = render( + + Brand + + ); + expect(screen.getByTestId('brand')).toHaveClass('has-text-info'); + + rerender( + + Brand + + ); + const brand = screen.getByTestId('brand'); + expect(brand).toHaveClass('has-text-grey'); + expect(brand).not.toHaveClass('has-text-info'); + expect(brand).not.toHaveAttribute('color'); + }); }); describe('Navbar.Item', () => { @@ -326,6 +356,28 @@ describe('Navbar.Burger', () => { render(); expect(ref.current).toBeInstanceOf(HTMLButtonElement); }); + + it('applies textColor as a helper class and not as a DOM attribute', () => { + render(); + const burger = screen.getByTestId('burger'); + expect(burger).toHaveClass('has-text-primary'); + expect(burger).not.toHaveAttribute('textColor'); + }); + + it('renders color as a text color, with textColor taking precedence', () => { + const { rerender } = render( + + ); + expect(screen.getByTestId('burger')).toHaveClass('has-text-info'); + + rerender( + + ); + const burger = screen.getByTestId('burger'); + expect(burger).toHaveClass('has-text-grey'); + expect(burger).not.toHaveClass('has-text-info'); + expect(burger).not.toHaveAttribute('color'); + }); }); describe('Navbar.Menu', () => { @@ -356,6 +408,36 @@ describe('Navbar.Menu', () => { ); expect(screen.getByTestId('menu')).toHaveClass('custom-menu'); }); + + it('applies textColor as a helper class and not as a DOM attribute', () => { + render( + + Menu + + ); + const menu = screen.getByTestId('menu'); + expect(menu).toHaveClass('has-text-primary'); + expect(menu).not.toHaveAttribute('textColor'); + }); + + it('renders color as a text color, with textColor taking precedence', () => { + const { rerender } = render( + + Menu + + ); + expect(screen.getByTestId('menu')).toHaveClass('has-text-info'); + + rerender( + + Menu + + ); + const menu = screen.getByTestId('menu'); + expect(menu).toHaveClass('has-text-grey'); + expect(menu).not.toHaveClass('has-text-info'); + expect(menu).not.toHaveAttribute('color'); + }); }); describe('Navbar.Start & Navbar.End', () => { @@ -378,6 +460,66 @@ describe('Navbar.Start & Navbar.End', () => { render(End); expect(screen.getByTestId('end')).toHaveClass('navbar-end'); }); + + it('applies textColor on Navbar.Start as a helper class and not as a DOM attribute', () => { + render( + + Start + + ); + const start = screen.getByTestId('start'); + expect(start).toHaveClass('has-text-primary'); + expect(start).not.toHaveAttribute('textColor'); + }); + + it('applies textColor on Navbar.End as a helper class and not as a DOM attribute', () => { + render( + + End + + ); + const end = screen.getByTestId('end'); + expect(end).toHaveClass('has-text-primary'); + expect(end).not.toHaveAttribute('textColor'); + }); + + it('renders color as a text color on Navbar.Start, with textColor taking precedence', () => { + const { rerender } = render( + + Start + + ); + expect(screen.getByTestId('start')).toHaveClass('has-text-info'); + + rerender( + + Start + + ); + const start = screen.getByTestId('start'); + expect(start).toHaveClass('has-text-grey'); + expect(start).not.toHaveClass('has-text-info'); + expect(start).not.toHaveAttribute('color'); + }); + + it('renders color as a text color on Navbar.End, with textColor taking precedence', () => { + const { rerender } = render( + + End + + ); + expect(screen.getByTestId('end')).toHaveClass('has-text-info'); + + rerender( + + End + + ); + const end = screen.getByTestId('end'); + expect(end).toHaveClass('has-text-grey'); + expect(end).not.toHaveClass('has-text-info'); + expect(end).not.toHaveAttribute('color'); + }); }); describe('Navbar.Dropdown', () => { diff --git a/docs/docs/api/components/navbar.md b/docs/docs/api/components/navbar.md index 71616b1ab..93ecc483e 100644 --- a/docs/docs/api/components/navbar.md +++ b/docs/docs/api/components/navbar.md @@ -519,13 +519,13 @@ You can use all [Bulma helper props](../helpers/usebulmaclasses.md) with `` attributes and Bulma helper props | — | See [Helper Props](../helpers/usebulmaclasses.md) | +| Prop | Type | Default | Description | +| ----------- | ------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `className` | `string` | — | Additional CSS classes. | +| `textColor` | [Bulma color](../helpers/valid-values.md) \| `'inherit'` \| `'current'` | — | Text color for the brand. | +| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Renders `has-text-`, exactly like `textColor`. Bulma has no `.navbar-brand.is-` rule, so this is not a filled variant. `textColor` takes precedence when both are set, and is the one that reaches the full color list. | +| `children` | `React.ReactNode` | — | Brand content. | +| `...` | All standard `
` attributes and Bulma helper props | — | See [Helper Props](../helpers/usebulmaclasses.md) | ### Navbar.Item @@ -555,49 +555,49 @@ You can use all [Bulma helper props](../helpers/usebulmaclasses.md) with `` in the burger as a bar, so an extra span here draws an extra bar. | -| `aria-label` | `string` | — | Aria label for accessibility. | -| `aria-expanded` | `boolean` | `false` | Aria expanded state. | -| `onClick` | `React.MouseEventHandler` | — | Click handler. | -| `ref` | `React.Ref` | — | Ref forwarded to the burger button element. | -| `...` | All standard `