Skip to content

Commit

Permalink
Merge pull request #455 from cheeto-bandito/bug/button-link
Browse files Browse the repository at this point in the history
SUGCON 2024: Navigation Link Placeholder
  • Loading branch information
lovesitecore authored Apr 19, 2024
2 parents 7d14138 + ac79f62 commit 33bb3bc
Show file tree
Hide file tree
Showing 25 changed files with 637 additions and 208 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Box, Link } from '@chakra-ui/react';
import { ButtonLink } from 'src/basics/ButtonLink';
import { LinkField, Link as JssLink } from '@sitecore-jss/sitecore-jss-nextjs';

// Define the type of props that Link will accept
Expand All @@ -24,3 +25,9 @@ export const Default = (props: LinkProps): JSX.Element => {
</Box>
);
};

export const Button = (props: LinkProps): JSX.Element => {
return (
<ButtonLink field={props.fields.Link} />
);
};
20 changes: 7 additions & 13 deletions src/Project/Sugcon2024/Sugcon/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ComponentParams,
ComponentRendering,
LinkField,
Placeholder,
Link as SitecoreLink,
Text,
TextField,
Expand All @@ -26,7 +27,6 @@ import {
HeaderHeights,
PaddingX,
PaddingY,
responsiveButtonSizeConfig,
} from 'template/LayoutConstants';

export interface Fields {
Expand All @@ -40,14 +40,11 @@ export interface Fields {
Styles: string[];
}

export type CustomComponentRendering = Omit<ComponentRendering, 'fields'> & {
fields: Fields[];
};

export type NavigationProps = {
params?: ComponentParams;
fields: Fields;
rendering: CustomComponentRendering;
rendering: ComponentRendering;
className?: string;
};

Expand Down Expand Up @@ -107,6 +104,7 @@ export const Default = (props: NavigationProps): JSX.Element => {
navigationMenuItems={navigationMenuItems}
onToggle={onToggle}
pageEditing={pageEditing}
rendering={props.rendering}
/>
);

Expand Down Expand Up @@ -149,15 +147,17 @@ interface ResponsiveNavigationProps {
navigationMenuItems: Fields[];
onToggle?: () => void;
pageEditing: boolean | undefined;
rendering: ComponentRendering;
}

const ResponsiveNavigation = ({
navigationMenuItems,
onToggle,
pageEditing,
rendering
}: ResponsiveNavigationProps): JSX.Element => {
return (
<Box as="nav" role="navigation" aria-label="SUGCON Europe 2024" ml={{ base: 0, lg: 'auto' }}>
<Box as="nav" role="navigation" aria-label="SUGCON" ml={{ base: 0, lg: 'auto' }}>
<UnorderedList
display={{ base: 'block', lg: 'flex' }}
flexWrap="wrap"
Expand Down Expand Up @@ -194,13 +194,7 @@ const ResponsiveNavigation = ({
);
})}
<ListItem>
<Button
as={Link}
href="https://siteco.re/SUGCONEurope2024Registration"
size={responsiveButtonSizeConfig}
>
Register now
</Button>
<Placeholder name="button-link" rendering={rendering} />
</ListItem>
</UnorderedList>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Meta, StoryObj } from '@storybook/react';
import { Button as ButtonLink } from '../../../components/Basic Components/Link';
const meta = {
title: 'Basic Components/Link',
component: ButtonLink,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {},
} satisfies Meta<typeof ButtonLink>;
export default meta;
type Story = StoryObj<typeof meta>;

export const Button: Story = {
name: 'Button',
args: {
params: {
styles: '',
},
fields: {
Link: {
value: {
href: 'https://www.google.com',
text: 'Register Now',
linktype: 'external'
},
},
},
},
};

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const meta = {
} satisfies Meta<typeof LinkComponent>;
export default meta;
type Story = StoryObj<typeof meta>;

export const Link: Story = {
name: 'Link',
args: {
Expand All @@ -30,4 +31,4 @@ export const Link: Story = {
},
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,96 +31,6 @@ export const PrimaryNavigation: Story = {
uid: '101b1558-808e-4d52-9ce5-6781dd2fc046',
componentName: 'Navigation',
dataSource: '',
params: {
FieldNames: 'Default',
LevelFrom: '{1BB88840-5FB3-4353-AD8D-81136F6FF75A}',
LevelTo: '{A59325BB-5A27-46F9-8110-9D499715F3BE}',
Styles: 'navigation-horizontal',
},
fields: [
{
Id: '9dc1fb0c-996c-4130-bc07-d5773bf2e824',
Styles: ['level1', 'submenu', 'item0', 'odd', 'first'],
Href: '/Sessssions',
Querystring: '',
NavigationTitle: {
value: 'Sessions',
editable: 'Sessions',
},
Children: [
{
Id: 'ffaa7f0d-2fb9-4c57-8846-5a55c7969fbf',
Styles: ['level2', 'item0', 'odd', 'first'],
Href: '/Sessions/Session-1',
Querystring: '',
NavigationTitle: {
value: 'Session 1',
editable: 'Session 1',
},
},
{
Id: 'bed50e98-2c1a-402e-a8ac-329015cc4b43',
Styles: ['level2', 'item1', 'even', 'last'],
Href: '/Sessions/Session-2',
Querystring: '',
NavigationTitle: {
value: 'Session 2',
editable: 'Session 2',
},
},
],
},
{
Id: '20434b37-8963-41c7-88bb-0d63af1854d1',
Styles: ['level1', 'item1', 'even'],
Href: '/Agenda',
Querystring: '',
NavigationTitle: {
value: 'Agenda',
editable: 'Agenda',
},
},
{
Id: 'f9718ba4-5378-43c1-89cd-537301b81f1b',
Styles: ['level1', 'item2', 'odd'],
Href: '/Speakers',
Querystring: '',
NavigationTitle: {
value: 'Speakers',
editable: 'Speakers',
},
},
{
Id: '0fbd1460-52d5-467a-accd-f955d448ae1d',
Styles: ['level1', 'item3', 'even'],
Href: '/Trainings',
Querystring: '',
NavigationTitle: {
value: 'Trainings',
editable: 'Trainings',
},
},
{
Id: '96b9ccc8-50fe-4493-8a2c-62807499262d',
Styles: ['level1', 'item4', 'odd'],
Href: '/Sponsors',
Querystring: '',
NavigationTitle: {
value: 'Sponsors',
editable: 'Sponsors',
},
},
{
Id: 'e5525fb5-fa3d-4eeb-a354-a30d01d79296',
Styles: ['level1', 'item5', 'even', 'last'],
Href: '/Organizers',
Querystring: '',
NavigationTitle: {
value: 'Organizers',
editable: 'Organizers',
},
},
],
},
fields: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 33bb3bc

Please sign in to comment.