-
Notifications
You must be signed in to change notification settings - Fork 400
Desktop landing pages #2649
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
Desktop landing pages #2649
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { compose } from 'redux'; | ||
|
||
import { categoriesFetch } from 'core/actions/categories'; | ||
import translate from 'core/i18n/translate'; | ||
import { getCategoryColor, visibleAddonType } from 'core/utils'; | ||
import Button from 'ui/components/Button'; | ||
import Card from 'ui/components/Card'; | ||
import type { DispatchFunc } from 'core/types/redux'; | ||
import LoadingText from 'ui/components/LoadingText'; | ||
|
||
import './styles.scss'; | ||
|
||
|
||
type CategoriesHeaderProps = { | ||
addonType: string, | ||
dispatch: DispatchFunc, | ||
categories: Object, | ||
clientApp: string, | ||
error: boolean | null, | ||
loading: boolean, | ||
i18n: Object, | ||
} | ||
|
||
export class CategoriesHeaderBase extends React.Component { | ||
componentWillMount() { | ||
const { addonType, clientApp, dispatch } = this.props; | ||
const categories = this.props.categories[addonType] || {}; | ||
|
||
if (!Object.values(categories).length) { | ||
dispatch(categoriesFetch({ addonType, clientApp })); | ||
} | ||
} | ||
|
||
props: CategoriesHeaderProps; | ||
|
||
render() { | ||
const { addonType, error, loading, i18n } = this.props; | ||
const categories = this.props.categories[addonType] ? | ||
Object.values(this.props.categories[addonType]) : []; | ||
|
||
if (error) { | ||
return ( | ||
<Card className="CategoriesHeader"> | ||
<p>{i18n.gettext('Failed to load categories.')}</p> | ||
</Card> | ||
); | ||
} | ||
|
||
if (!loading && !categories.length) { | ||
return ( | ||
<Card className="CategoriesHeader"> | ||
<p>{i18n.gettext('No categories found.')}</p> | ||
</Card> | ||
); | ||
} | ||
|
||
return ( | ||
<Card className="CategoriesHeader" header={i18n.gettext('Categories')}> | ||
{loading ? | ||
<div className="CategoriesHeader-loading"> | ||
<span className="CategoriesHeader-loading-info visually-hidden"> | ||
{i18n.gettext('Loading categories.')} | ||
</span> | ||
{Array(8).fill(0).map((value, index) => { | ||
return ( | ||
<LoadingText | ||
className="CategoriesHeader-loading-text" | ||
key={`CategoriesHeader-loading-text-${index}`} | ||
maxWidth={20} | ||
range={3} | ||
/> | ||
); | ||
})} | ||
</div> | ||
: | ||
<ul className="CategoriesHeader-list"> | ||
{categories.map((category, index) => ( | ||
<li | ||
className="CategoriesHeader-item" | ||
key={`category-${index}`} | ||
> | ||
<Button | ||
className={`CategoriesHeader-link Button--action | ||
Button--small | ||
CategoriesHeader--category-color-${getCategoryColor(category)}`} | ||
to={`/${visibleAddonType(addonType)}/${category.slug}/`} | ||
> | ||
{category.name} | ||
</Button> | ||
</li> | ||
))} | ||
</ul> | ||
} | ||
</Card> | ||
); | ||
} | ||
} | ||
|
||
export function mapStateToProps(state) { | ||
const clientApp = state.api.clientApp; | ||
const categories = state.categories.categories[clientApp]; | ||
|
||
return { | ||
categories, | ||
clientApp, | ||
error: state.categories.error, | ||
loading: state.categories.loading, | ||
}; | ||
} | ||
|
||
export default compose( | ||
connect(mapStateToProps), | ||
translate({ withRef: true }), | ||
)(CategoriesHeaderBase); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@import "~amo/css/inc/vars"; | ||
@import "~core/css/inc/mixins"; | ||
@import "~ui/css/vars"; | ||
|
||
.CategoriesHeader .Card-contents { | ||
display: flex; | ||
} | ||
|
||
.CategoriesHeader-loadingText { | ||
@include margin-end(5px); | ||
} | ||
|
||
.CategoriesHeader-list { | ||
display: block; | ||
list-style: none; | ||
margin: 0 auto; | ||
padding: 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see a couple instances of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're for |
||
} | ||
|
||
.CategoriesHeader-item { | ||
@include margin-end(5px); | ||
|
||
display: inline-block; | ||
margin: 0 0 5px; | ||
padding: 0; | ||
} | ||
|
||
@for $i from 1 through 12 { | ||
.CategoriesHeader--category-color-#{$i} { | ||
background: desaturate(nth($category-colors, $i), 20); | ||
} | ||
} | ||
|
||
@for $i from 1 through 10 { | ||
.CategoriesHeader--type-extension.CategoriesHeader--category-color-#{$i} { | ||
background: desaturate(nth($category-colors-extensions, $i), 20); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@import "~amo/css/inc/vars"; | ||
@import "~core/css/inc/mixins"; | ||
|
||
.LandingPage { | ||
padding: $padding-page; | ||
} | ||
|
||
.LandingPage-icon--persona { | ||
@include margin-end(20px); | ||
} | ||
|
||
.LandingPage-header { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: row; | ||
font-size: $font-size-default; | ||
justify-content: center; | ||
margin: $padding-page auto ($padding-page * 2); | ||
max-width: 600px; | ||
} | ||
|
||
.LandingPage-button { | ||
display: block; | ||
|
||
@include respond-to(medium) { | ||
display: none; | ||
} | ||
} | ||
|
||
.LandingPage-icon { | ||
height: 89px; | ||
width: 225px; | ||
|
||
@include respond-to(medium) { | ||
height: 178px; | ||
width: 450px; | ||
} | ||
} | ||
|
||
.LandingPage-addonType-name { | ||
font-size: $font-size-l; | ||
margin: 0; | ||
|
||
@include respond-to(medium) { | ||
font-size: $font-size-xl; | ||
} | ||
} | ||
|
||
.LandingPage-heading-content { | ||
font-size: $font-size-s; | ||
margin: 0; | ||
max-width: 480px; | ||
} | ||
|
||
.LandingPage .CategoriesHeader { | ||
display: none; | ||
|
||
@include respond-to(medium) { | ||
display: block; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure there's a bug on file to merge this with
src/amo/components/Categories