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: Allignment issue in the blog page #1029

Merged
merged 12 commits into from
Oct 26, 2024
68 changes: 60 additions & 8 deletions pages/blog/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import { useRouter } from 'next/router';
import useSetUrlParam from '~/lib/useSetUrlParam';
import { SectionContext } from '~/context';

type Author = {
name: string;
photo?: string;
link?: string;
byline?: string;
};
export type blogCategories =
| 'All'
| 'Community'
Expand Down Expand Up @@ -286,14 +292,34 @@ export default function StaticMarkdownPage({
/>
</div>
</div>
<div className='flex flex-row items-center'>
<div className='flex flex-row pl-2 mr-2'>
<div
className={`
flex
flex-row
items-center
`}
>
<div
className={`
flex
flex-row
pl-2
mr-2
`}
>
{(frontmatter.authors || []).map(
(author: any, index: number) => {
(author: Author, index: number) => {
return (
<div
key={index}
className='bg-slate-50 h-[44px] w-[44px] rounded-full -ml-3 bg-cover bg-center border-2 border-white'
className={`bg-slate-50
${frontmatter.authors.length > 2 ? 'h-8 w-8' : 'h-11 w-11'}
rounded-full
-ml-3
bg-cover
bg-center
border-2
border-white`}
style={{
backgroundImage: `url(${author.photo})`,
zIndex: 10 - index,
Expand All @@ -304,11 +330,37 @@ export default function StaticMarkdownPage({
)}
</div>

<div className='flex flex-col items-start'>
<div
className={`
flex
flex-col
items-start
`}
>
<div className='text-sm font-semibold'>
{frontmatter.authors
.map((author: any) => author.name)
.join(' & ')}
{frontmatter.authors.length > 2 ? (
<>
{frontmatter.authors
.slice(0, 2)
.map((author: Author, index: number) => (
<span key={author.name}>
{author.name}
{index === 0 && ' & '}
</span>
))}
{'...'}
</>
) : (
frontmatter.authors.map(
(author: Author, index: number) => (
<span key={author.name}>
{author.name}
{index < frontmatter.authors.length - 1 &&
' & '}
</span>
),
)
)}
</div>

<div className='text-slate-500 text-sm dark:text-slate-300'>
Expand Down
28 changes: 25 additions & 3 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ module.exports = {
'./components/**/*.{js,ts,jsx,tsx,md}',
],
darkMode: "class",
safelist: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than adding elements to the safelist here we should check for other alternatives like making sure we are adding styles without using string concatenation to create class names:

https://v2.tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html

'flex',
'flex-row',
'items-center',
'pl-2',
'mr-2',
'h-8',
'h-11',
'w-8',
'w-11',
'rounded-full',
'bg-cover',
'bg-center',
'border-2',
'border-white',
'-ml-3',
'text-sm',
'font-semibold',
'text-slate-500',
'dark:text-slate-300',
// Add other dynamic classes if needed
],
theme: {
screens: {
'sm': '640px',
Expand All @@ -20,7 +42,7 @@ module.exports = {

'2xl': '1536px',
// => @media (min-width: 1536px) { ... }
'ab1':'890px'
'ab1': '890px'

},
fontFamily: {
Expand All @@ -43,13 +65,13 @@ module.exports = {
'h4mobile': '22px',
'h5mobile': '20px'
},

extend: {
backgroundImage: {
'gradient-radial': 'linear-gradient(72.68deg, #002CC4 28.97%, #5468FF 145.47%)',
},
colors: {

white: '#ffffff',
black: '#000000',
primary: '#002CC4',
Expand Down
Loading