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

Fix layout issues for speakersgrid and person components. #445

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/Project/Sugcon2024/Sugcon/src/Theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const Button = defineStyleConfig({
color: 'white',
},
},
link: {
fontSize: '18px',
fontWeight: 'bold',
color: 'black',
},
// Variant for Primary Navigation to make a Button look like a Link
navButtonLink: {
fontWeight: 'bold',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export const Default = (props: PersonProps): JSX.Element => {
<Image
as={JssImage}
src={props.fields.Image?.value?.src}
w={300}
w={260}
borderRadius={15}
mb={10}
onClick={props.params?.LinkToBio == '1' ? onOpen : undefined}
cursor="pointer"
field={props.fields.Image}
/>

Expand All @@ -82,10 +83,10 @@ export const Default = (props: PersonProps): JSX.Element => {
<JssText field={props.fields.Name} />
</Heading>
)}
<Text fontSize="18px" mb={0}>
<Text fontSize="16px" color="sugcon.gray.500" mb={0}>
<JssText field={props.fields.JobRole} />
</Text>
<Text fontSize="18px" mb={0}>
<Text fontSize="16px" color="sugcon.gray.500" mb={0}>
<JssText field={props.fields.Company} />
</Text>
{(isEditorActive() ||
Expand Down Expand Up @@ -138,16 +139,16 @@ export const Default = (props: PersonProps): JSX.Element => {
<Image src={props.fields.Image?.value?.src} w={200} borderRadius={15} />
</Box>
<Box w={{ base: '100%', md: '55%', lg: '60%' }}>
<Heading as="h3" size="lg">
<Heading as="h2" fontSize="25px">
{props.fields.Name?.value}
</Heading>
<Text fontSize="18px" mb={0}>
<Text fontSize="18px" mb="15px" color="#4D4D4D">
{props.fields.JobRole?.value}
</Text>
<Text fontSize="18px" mb={0}>
{props.fields.Company?.value}
</Text>
<Text as={JssRichText} fontSize="18px" mb={0} field={props.fields.Biography} />
<Text as={JssRichText} fontSize="18px" mb="15px" field={props.fields.Biography} />
</Box>
</Flex>
</ModalBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { Box, Heading, SimpleGrid } from '@chakra-ui/react';
import { TextField, Text as JssText } from '@sitecore-jss/sitecore-jss-nextjs';
import { PersonFields, PersonProps, Default as Person } from '../Basic Components/Person';
import { isEditorActive } from '@sitecore-jss/sitecore-jss-nextjs/utils';
import clsx from 'clsx';
import { LayoutFlex } from 'components/Templates/LayoutFlex';

Expand Down Expand Up @@ -50,11 +49,8 @@ export const Default = (props: PeopleGridProps): JSX.Element => {
return (
<Box w="100%" mt={20} className={clsx(props?.params?.Styles)}>
<LayoutFlex flexGrow="1" flexDirection="column" align="start">
{(isEditorActive() || props.fields?.Headline?.value !== '') && (
<Heading as="h2" size="lg">
<JssText field={props.fields.Headline} />
</Heading>
)}
<Heading as={JssText} field={props.fields.Headline} tag="h2" size="lg" />

<SimpleGrid
w="full"
columns={{ base: 1, md: Math.ceil(cols / 2), xl: cols }} // Using Math.ceil so odd numbers round up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useState, useEffect } from 'react';
import { Box, Heading, SimpleGrid } from '@chakra-ui/react';
import { Field, TextField, Text as JssText } from '@sitecore-jss/sitecore-jss-nextjs';
import { PersonFields, PersonProps, Default as Person } from '../Basic Components/Person';
import { isEditorActive } from '@sitecore-jss/sitecore-jss-nextjs/utils';
import * as cheerio from 'cheerio';
import clsx from 'clsx';

// Define the type of props that People Grid will accept
interface Fields {
Expand Down Expand Up @@ -101,8 +101,7 @@ function getPeople(sessionTitle: string, body: string) {
}

export const Default = (props: PeopleGridProps): JSX.Element => {
const styles = props.params && props.params.Styles ? props.params.Styles : '';
const cols = props.params && props.params.Columns ? parseInt(props.params.Columns) : 4;
const cols = props.params && props.params.Columns ? parseInt(props.params.Columns) : 5;

const [people, setPeople] = useState(Array<PersonItem>);

Expand All @@ -128,23 +127,24 @@ export const Default = (props: PeopleGridProps): JSX.Element => {
}

return (
<Box w="100%" mt={20} className={styles}>
<Box w="80%" pt={10} m="auto">
{(isEditorActive() || props.fields?.Headline?.value !== '') && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was there to make sure the headline field shows in editor mode, but hides the heading field if the field is empty in regular mode. Otherwise you still have the space from an empty h2 tag.

Copy link
Contributor Author

@matthewgisonno matthewgisonno Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericsanner good call... I made a change to the whole usage so that it uses the JssText component, which handles the conditional rendering. If the field is empty and it's not pageEditing mode, the tag is not rendered. If the field is empty and it's in pageEditing mode, the tag is rendered so it can be edited.

<Heading as={JssText} field={props.fields.Headline} tag="h2" size="lg" />

That way the logic of showing and hiding the tag is offloaded to the JssText component and the rendering is handled by Chakra Heading component. JssText allows for a field and tag attribute as well, which are implemented here.

<Heading as="h2" size="lg">
<JssText field={props.fields.Headline} />
</Heading>
)}
<SimpleGrid columns={{ base: 1, md: cols }} mt={10}>
{people.map((person, idx) => {
const pp: PersonProps = {
params: props.params,
fields: person.fields,
};
return <Person key={idx} {...pp}></Person>;
})}
</SimpleGrid>
</Box>
<Box w="100%" pr="0" pl="0" className={clsx(props?.params?.Styles)}>
<Heading as={JssText} field={props.fields.Headline} tag="h2" size="lg" />

<SimpleGrid
w="full"
columns={{ base: 1, md: 2, lg: Math.ceil(cols / 2), xl: cols }} // Using Math.ceil so odd numbers round up.
mt={10}
gap="18px"
justifyItems="center"
>
{people.map((person, idx) => {
const pp: PersonProps = {
params: props.params,
fields: person.fields,
};
return <Person key={idx} {...pp}></Person>;
})}
</SimpleGrid>
</Box>
);
};
Loading