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

Enter initial design #8

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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,8 +1,8 @@
.language-switcher {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: var(--language-bar-height);
width: 100%;
}

Expand All @@ -15,20 +15,37 @@
margin: 0 0.5rem;
}

.language-switcher li a {
color: var(--color-text);
.language-switcher li button {
color: var(--colors-surface-primary);
text-decoration: none;
font-size: 1rem;
font-weight: 500;
text-transform: uppercase;
transition: color 0.2s ease-in-out;

&:hover {
text-decoration: underline;
}
transition:
color 0.5s ease-in-out,
background-color 0.2s ease-in-out;
border: 2px solid var(--colors-surface-primary);
border-radius: 0.5rem;
padding: 0.5rem 0.8rem;
background: transparent;

&.active {
font-weight: 700;
text-decoration: underline;
color: coral;
border-color: coral;
}
}

.language-switcher li button:hover:not(.active) {
cursor: pointer;
background-color: coral;
color: var(--colors-surface-primary);
border-color: var(--colors-surface-primary);
}

.language__title {
font-size: 1rem;
margin-bottom: 1.5rem;
color: var(--colors-surface-primary);
padding-bottom: 0.25rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import i18nConfig from 'i18nConfig';
import styles from './LanguageSwitcher.module.css';

export const LanguageSwitcher = (): JSX.Element => {
const { i18n } = useTranslation();
const { t, i18n } = useTranslation();

const languages = i18nConfig.locales;
const currentLocale = i18n.language;

Expand All @@ -28,6 +29,7 @@ export const LanguageSwitcher = (): JSX.Element => {

return (
<div data-testid="language-switcher" className={styles['language-switcher']}>
<p className={styles.language__title}>{t('language')}</p>
<ul role="listbox">
{languages.map(language => (
<li key={language}>
Expand Down
12 changes: 9 additions & 3 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
'use client';
import styles from '@/styles/Welcome.module.css';
adriamarcet marked this conversation as resolved.
Show resolved Hide resolved

import { LanguageSwitcher } from '@/Shared/ui/components/LanguageSwitcher';

import { useTranslation } from 'react-i18next';

export default function Home() {
const { t } = useTranslation('common');
return (
<main>
<h1>Runroom - NextJS Starter</h1>
<p>{t('language')}</p>
<main className={styles.welcome}>
<h1 className={styles.welcome__title}>
<span className={styles.welcome__gradient}>Runroom Starter</span>
<span className={`${styles.welcome__gradient} ${styles.welcome__below}`}>
{t(`welcome`)}
</span>
</h1>
<LanguageSwitcher />
</main>
);
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ca/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"locale": "ca",
"language": "Català"
"language": "Català",
"welcome": "Starter amb Next JS"
}
3 changes: 2 additions & 1 deletion src/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"locale": "en",
"language": "English"
"language": "English",
"welcome": "with Next JS"
}
3 changes: 2 additions & 1 deletion src/locales/es/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"locale": "es",
"language": "Español"
"language": "Español",
"welcome": "Starter con Next JS"
}
62 changes: 62 additions & 0 deletions src/styles/Welcome.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.welcome {
--main-size: 3.125rem;

background: var(--colors-surface-secondary);
padding: 8rem 0;
justify-content: space-between;
}

.welcome__title {
color: var(--colors-surface-primary);
display: flex;
flex-direction: column;
font-size: var(--main-size);
font-weight: 700;
line-height: 1;
margin-bottom: 1em;
text-align: center;
}

@property --i {
syntax: "<color>";
inherits: false;
initial-value: white;
}

.welcome__gradient {
--i: white;

background: linear-gradient(to bottom, var(--i) 20%, var(--colors-surface-secondary));
background-clip: text;
background-size: 400%;
background-position: 0%;
transition: background 0.5s;
}

.welcome__title:hover .welcome__gradient {
--i: coral;

cursor: crosshair;
}

.welcome__below {
font-size: calc(var(--main-size) - 1.5rem);
margin-top: -0.25rem;
}

@media (width >= 768px) {
.welcome {
--main-size: 6rem;

padding: 4rem 0;
}

.welcome__title {
max-width: 14ch;
padding-top: 4rem;
}

.welcome__below {
margin-top: -1.25rem;
}
}
4 changes: 3 additions & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ body {
}

main {
--accent-color: coral;

display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
padding: 6rem;
min-height: 100vh;
width: 100%;
}

/* stylelint-disable-next-line */
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Page', () => {
it('should navigate between pages', () => {
cy.visit('/');

cy.get('h1').contains('Runroom - NextJS Starter');
cy.get('h1').contains('Runroom Starter');
adriamarcet marked this conversation as resolved.
Show resolved Hide resolved
});
});

Expand Down
Loading