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

convert Home page to use TypeScript #3124

Merged
merged 2 commits into from
Nov 20, 2023
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import FlatButton from 'material-ui/FlatButton';
import { connect } from 'react-redux';
import { IconSteam } from '../Icons';
import { ButtonsDiv } from './Styled';
import config from '../../config';

const Buttons = ({ user, strings }) => (
import { HomePageProps } from './Home';

const Buttons = ({ user, strings }: HomePageProps) => (
<ButtonsDiv>
{
!user &&
Expand All @@ -30,12 +31,7 @@ const Buttons = ({ user, strings }) => (
</ButtonsDiv>
);

Buttons.propTypes = {
user: PropTypes.shape({}),
strings: PropTypes.shape({}),
};

const mapStateToProps = (state) => {
const mapStateToProps = (state: any) => {
const { data } = state.app.metadata;
return {
user: data.user,
Expand Down
28 changes: 14 additions & 14 deletions src/components/Home/Home.jsx → src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import Buttons from './Buttons';
import Why from './Why';
import Sponsors from './Sponsors';
import { HeadContainerDiv, HeadlineDiv, DescriptionDiv, BottomTextDiv } from './Styled';

const Home = ({ strings }) => (
export interface HomePageProps {
user?: string;
strings: { [key: string]: string };
}

const Home = ({ strings }: HomePageProps) => (
<div>
<HeadContainerDiv>
<HeadlineDiv>
Expand All @@ -15,29 +19,25 @@ const Home = ({ strings }) => (
<DescriptionDiv>
<h2>{strings.app_description}</h2>
</DescriptionDiv>
<Buttons />
<Buttons strings={strings} />
</HeadContainerDiv>
<Why />
<Sponsors />
<BottomTextDiv>
<span id="bg-image-description">{strings.home_background_by}</span>
<a
href="//www.artstation.com/artist/mikeazevedo"
target="_blank"
rel="noopener noreferrer"
aria-describedby="bg-image-description"
<a
href="//www.artstation.com/artist/mikeazevedo"
target="_blank"
rel="noopener noreferrer"
aria-describedby="bg-image-description"
aria-label="Mike Azevedo on artstation.com"
> Mike Azevedo
</a>
</a>
</BottomTextDiv>
</div>
);

Home.propTypes = {
strings: PropTypes.shape({}),
};

const mapStateToProps = state => ({
const mapStateToProps = (state: any) => ({
content: state.content,
strings: state.app.strings,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import FlatButton from 'material-ui/FlatButton';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { ButtonsDiv } from './Styled';
import config from '../../config';

import { HomePageProps } from './Home';

const StyledDiv = styled.div`
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -34,11 +35,11 @@ const StyledDiv = styled.div`
}
`;

const Sponsors = ({ strings }) => (
const Sponsors = ({ strings }: HomePageProps) => (
<StyledDiv>
<div className="headline">{strings.home_sponsored_by}</div>
<div className="images">
{config.VITE_ENABLE_DOTA_COACH && (
{config.VITE_ENABLE_DOTACOACH && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also fixes a typo here.

<a
href="https://dota-coach.com?s=OpenDota&c=main"
target="_blank"
Expand Down Expand Up @@ -84,11 +85,7 @@ const Sponsors = ({ strings }) => (
</StyledDiv>
);

Sponsors.propTypes = {
strings: PropTypes.shape({}),
};

const mapStateToProps = (state) => ({
const mapStateToProps = (state: any) => ({
strings: state.app.strings,
});

Expand Down
File renamed without changes.
11 changes: 4 additions & 7 deletions src/components/Home/Why.jsx → src/components/Home/Why.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import styled from 'styled-components';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { IconOpenSource, IconStatsBars, IconWand } from '../Icons';
import constants from '../constants';

import { HomePageProps } from './Home';

const StyledDiv = styled.div`
margin: 50px auto 0;
text-align: center;
Expand Down Expand Up @@ -50,7 +51,7 @@ const StyledDiv = styled.div`
}
`;

const Why = ({ strings }) => (
const Why = ({ strings }: HomePageProps) => (
<StyledDiv>
<div className="whyList">
<div className="whyElement">
Expand Down Expand Up @@ -84,11 +85,7 @@ const Why = ({ strings }) => (
</StyledDiv>
);

Why.propTypes = {
strings: PropTypes.shape({}),
};

const mapStateToProps = state => ({
const mapStateToProps = (state: any) => ({
strings: state.app.strings,
});

Expand Down
File renamed without changes.