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

feat: new style for "package" headers #856

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions app/helpers/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper } from '@ember/component/helper';

export function sub(params) {
return params[0] - params[1];
}

export default helper(sub);
4 changes: 4 additions & 0 deletions app/models/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { belongsTo, attr } from '@ember-data/model';
import ClassModel from './class';

export default class Module extends ClassModel {
get nameParts() {
return this.name ? this.name.split('/') : [];
}

@attr()
submodules;

Expand Down
7 changes: 5 additions & 2 deletions app/routes/project-version/classes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
@service
metaStore;

@service
store;

titleToken(model) {
return model.name;
}
Expand All @@ -37,13 +40,13 @@ export default class ClassRoute extends Route.extend(ScrollTracker) {
}

find(typeName, param) {
return this.store.find(typeName, param).catch((e1) => {
return this.store.findRecord(typeName, param).catch((e1) => {
if (typeName != 'namespace') {
console.warn(
e1,
'fetching by class or module failed, retrying as namespace'
);
return this.store.find('namespace', param).catch((e2) => {
return this.store.findRecord('namespace', param).catch((e2) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change should be separated out and landed irregardless, this code is deprecated and will break in 5.0 @jaredgalanis @jenweber

console.error(e2);
return resolve({
isError: true,
Expand Down
92 changes: 92 additions & 0 deletions app/styles/_class.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,98 @@
article.chapter {
h1.module-name {
display: inline;
color: #4d4d4d;
font-size: 1.2em;

span.title-badge {
display: inline-block;
margin-left: 0.5em;
vertical-align: middle;
font-size: 0.5em;
font-weight: 500;
color: $white;
padding: 0.2em 0.5em;
border-radius: 3px;
background-color: $light-brown;
}
}

h1.package-name {
display: inline;

span.package-title-badge {
display: inline-block;
margin-left: 0em;
vertical-align: middle;
font-size: 0.5em;
font-weight: 500;
line-height: 1em;
color: $white;
padding: 0.2em 0.5em;
border-radius: 3px 0 0 3px;
background-color: $brown;
position: relative;
z-index: 1;

// arrow right
&::after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: .7em solid transparent;
border-bottom: .7em solid transparent;
border-left: .6em solid $brown;
position: absolute;
top: 50%;
margin-top: -.7em;
left: 100%;
z-index: 2;
}
}

span.package-title-part {
display: inline-block;
margin-left: 0.5em;
vertical-align: middle;
font-size: 0.5em;
font-weight: 500;
line-height: 1em;
color: $light-brown;
position: relative;
left: -1rem;
padding: 0.2em 0.5em 0.2em 0.2em;
border-radius: 0 3px 3px 0;
background-color: $light-gray;

&:nth-of-type(2) {
padding-left: 1.2em;
left: -1rem;
}
&:nth-of-type(3) {
left: -2rem;
// background-color: lighten($light-gray, 20%);
}
&:nth-of-type(4) {
left: -3rem;
// background-color: lighten($light-gray, 30%);
}

&:last-of-type::after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: .7em solid transparent;
border-bottom: .7em solid transparent;
border-left: .6em solid $light-gray;
position: absolute;
top: 50%;
margin-top: -.7em;
left: 100%;
z-index: 2;
}
}
}

.heading__link__edit {
Expand Down
1 change: 1 addition & 0 deletions app/styles/base/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $top-spacing: $base-spacing * 3.333; // 80px
$ember-orange: #dd6a58;
$light-brown: #b67d47;
$brown: #865931;
$light-gray: #eaeaea;
$medium-gray: #999;
$dark-gray: #444545;
$tan: #fffdf9;
Expand Down
14 changes: 12 additions & 2 deletions app/templates/project-version/modules/module.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<article class="chapter">
{{#if (eq this.model.name 'ember-data-overview')}}
<h1 class="module-name">EmberData Overview</h1>
<h1 class="module-name">EmberData</h1>
{{else if this.model.nameParts}}
<h1 class="package-name">
<span class="package-title-badge">Package</span>
{{~#each this.model.nameParts as |part index|~}}
<span class="package-title-part">{{part}}{{if (eq index (sub this.model.nameParts.length 1)) '' '/'}}</span>
{{~/each}}
</h1>
{{else}}
<h1 class="module-name">Package {{this.model.name}}</h1>
<h1 class="module-name">
{{this.model.name}}
<span class="title-badge">Package</span>
</h1>
{{/if}}
{{#if this.model.access}}<span class="access">{{this.model.access}}</span>{{/if}}

Expand Down