Skip to content
Open
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
24 changes: 24 additions & 0 deletions src-react/App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "./shared/scss/media";
@import "./shared/scss/theme_variables";

.body-cover {
width: 100%;
z-index: 0;
position: fixed;
height: 100%;
}

.wrapper {
position: relative;
width: 85%;
min-height: 80px;
margin: 0 auto;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 15px;
height: 100%;
line-height: 1.3;

@media #{$mobile-only} {
width: 100%;
}
}
18 changes: 17 additions & 1 deletion src-react/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { useSettings } from './shared/settings/SettingsContext';
import Footer from './core/footer/Footer';
import Header from './core/header/Header';
import './App.scss';

function App() {
return <h1>Angular 2 HN — React migration in progress</h1>;
const { settings } = useSettings();

return (
<div className={settings.theme}>
<div className="body-cover" />
<div className="wrapper">
<Header />
<div />
<Footer />
</div>
</div>
);
}

export default App;
23 changes: 23 additions & 0 deletions src-react/core/footer/Footer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@import "../../shared/scss/media";
@import "../../shared/scss/theme_variables";

#footer {
position: relative;
padding: 10px;
height: 60px;
letter-spacing: 0.7px;
text-align: center;

a {
font-weight: bold;
text-decoration: none;

&:hover {
text-decoration: underline;
}
}

@media #{$mobile-only} {
display: none;
}
}
16 changes: 16 additions & 0 deletions src-react/core/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import './Footer.scss';

function Footer() {
return (
<div id="footer">
<p>
Show this project some ❤ on{' '}
<a href="https://github.com/hdjirdeh/angular2-hn" target="_blank" rel="noopener">
GitHub
</a>
</p>
</div>
);
}

export default Footer;
149 changes: 149 additions & 0 deletions src-react/core/header/Header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
@import "../../shared/scss/media";
@import "../../shared/scss/theme_variables";

#header {
color: #fff;
padding: 6px 0;
line-height: 18px;
vertical-align: middle;
position: relative;
z-index: 1;
width: 100%;

@media #{$mobile-only} {
height: 50px;
position: fixed;
top: 0;
}

a {
display: inline;
}
}

.home-link {
width: 50px;
height: 66px;
}

.logo-inner {
width: 32px;
position: absolute;
left: 17px;
top: 18px;
z-index: -1;
height: 32px;
border-radius: 50%;

@media #{$mobile-only} {
left: 16px;
top: 12px;
}
}

.logo {
width: 50px;
padding: 3px 8px 0;

@media #{$mobile-only} {
width: 45px;
padding: 0 0 0 10px;
}
}

h1 {
font-weight: normal;
display: inline-block;
vertical-align:middle;
margin: 0;
font-size: 16px;

a {
color: #fff;
text-decoration: none;
}
}

.name {
margin-right: 30px;
margin-bottom: 2px;

@media #{$mobile-only} {
display: none;
}
}

.header-text {
position: absolute;
width: inherit;
height: 20px;
left: 10px;
top: 27px;
z-index: -1;

@media #{$mobile-only} {
top: 22px;
}
}

.left {
position: absolute;
left: 60px;
font-size: 16px;

@media #{$mobile-only} {
width: 100%;
left: 0;
}
}

.header-nav {
display: inline-block;
margin-left: 20px;

@media #{$mobile-only} {
margin-left: 60px;
}

a {
color: hsla(0,0%,100%,.9);
text-decoration: none;
margin: 0 5px;
letter-spacing: 1.8px;

&:hover {
color: #fff;
}
}

.active {
color: #fff;
}
}

.info {
position: absolute;
top: 0;
right: 20px;
height: 100%;

@media #{$mobile-only} {
right: 10px;
}

img {
opacity: 0.8;
width: 25px;
margin-top: 21.5px;
display: block;

&:hover {
opacity: 1;
cursor: pointer;
}

@media #{$mobile-only} {
margin-top: 15px;
}
}
}
53 changes: 53 additions & 0 deletions src-react/core/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { NavLink } from 'react-router-dom';

import { useSettings } from '../../shared/settings/SettingsContext';
import Settings from '../settings/Settings';
import './Header.scss';

function Header() {
const { settings, toggleSettings } = useSettings();
const scrollTop = () => window.scrollTo(0, 0);

return (
<header>
<div id="header">
<NavLink className="home-link" to="/news/1" onClick={scrollTop}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: NavLink active class relies on v6 string-append behavior

NavLink with a static string className="home-link" reproduces Angular's routerLinkActive="active" only because react-router-dom v6 appends active to string classNames when active. Confirmed against ^6.26.2 in package.json, so the port is faithful.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

<div className="logo-inner" />
<img className="logo" src="/assets/images/logo.svg" alt="Logo" />
</NavLink>
<div className="header-text">
<div className="left">
<span className="header-nav">
<NavLink to="/newest/1" onClick={scrollTop}>
new
</NavLink>
{' | '}
<NavLink to="/show/1" onClick={scrollTop}>
show
</NavLink>
{' | '}
<NavLink to="/ask/1" onClick={scrollTop}>
ask
</NavLink>
{' | '}
<NavLink to="/jobs/1" onClick={scrollTop}>
jobs
</NavLink>
</span>
</div>
</div>
<div className="info">
<img
className="settings"
src="/assets/images/cog.svg"
alt="Settings"
onClick={toggleSettings}
/>
</div>
</div>
{settings.showSettings && <Settings />}
</header>
);
}

export default Header;
74 changes: 74 additions & 0 deletions src-react/core/settings/Settings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@import "../../shared/scss/media";
@import "../../shared/scss/theme_variables";

.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
opacity: 1;
z-index: 1;
}

.popup {
margin: 70px auto;
padding: 30px;
border-radius: 5px;
width: 30%;
position: relative;
h1 {
margin-top: 0;
margin-bottom: 0px;
color: #fff;
text-align: center;
letter-spacing: 1px;
}
h2 {
padding-top: 10px;
}
hr {
width: 40%;
margin-bottom: 20px;
}
.close {
position: absolute;
top: 12px;
right: 20px;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: rgba(255,255,255,0.8);
&:hover {
color: #fff;
cursor: pointer;
}
}
.content {
max-height: 30%;
color: #fff;
letter-spacing: 1px;
overflow: auto;
}
input[type=number] {
display: block;
width: 80%;
height: 20px;
margin-bottom: 15px;
border-radius: 5px;
padding: 2px;
}
}

.control-section {
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid white;
}

@media screen and (max-width: 700px) {
.box, .popup {
width: 70%;
}
}
Loading