Skip to content

Commit

Permalink
Main site components (#104)
Browse files Browse the repository at this point in the history
* Add components for first section of main site

* Fix styling of title and caption

* Get main callout buttons working

* Style the main page callouts on mobile

* Style the code demo

* Get start of main page working on mobile and in color modes and spilt out into own page

* Get used by logos working

* Fix spacing

* Add Mastodon Link to site

* Add rel links to social accounts

* Add cards

* Get Vapor cards working

* Get next section looking OK

* Correct styling of code examples

* Don't try and connect to STS if in testing

* Sort out code examples styling

* Create some components and add details to code examples

* Make code error block responsive

* Make code blocks outline decoration responsive

* Major changes

* Should be done

* Add some pics and adjust stuff

* Update CI with correct S3 api rules

* Update highlight.js

* Update CI

* Update CI

* Update CI

* Update CI...

* Add scrolling navbar and fix some colors

* Update ci.yaml (#108)

* Gwynne is very slow on the uptake

* Fix some (though not all) issues

* Tighten up spacing

* Use SASS variable for colour

* Update webpack config

* Update CI

* Try using different S3 workflow

* Update CI

* Use relative paths

* Update webpack config

* Update CI

* Update CI

* Update CI and webpack config

* Update background compat

---------

Co-authored-by: Tim <0xtimc@gmail.com>
Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
Co-authored-by: Gwynne Raskind <gwynne@vapor.codes>
  • Loading branch information
4 people committed May 13, 2024
1 parent 9a62b3a commit 76e0153
Show file tree
Hide file tree
Showing 54 changed files with 2,094 additions and 947 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ jobs:
fi
- name: Deploy S3 Website
if: ${{ github.event.pull_request.head.repo.full_name == 'vapor/design' && github.actor != 'dependabot[bot]' }}
uses: rishabhrao/s3-website-https-pr-action@v1
uses: brokenhandsio/s3-website-https-pr-action@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
bucket-prefix: "vapor-design-pulls"
folder-to-copy: "./Output"
bucket-region: "us-east-1"
299 changes: 297 additions & 2 deletions Sources/DesignSite/DesignTheme.swift

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Sources/DesignSite/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct DesignSite: Website {
enum SectionID: String, WebsiteSectionID {
// Add the sections that you want your website to contain here:
case posts
case mainPageDemo
}

struct ItemMetadata: WebsiteItemMetadata {
Expand Down
22 changes: 22 additions & 0 deletions Sources/VaporDesign/Components/MainSite/CompanyCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Plot
import Publish

public struct CompanyCard: Component {
let name: String
let url: String
let logo: String

public init(name: String, url: String, logo: String) {
self.name = name
self.url = url
self.logo = logo
}

public var body: Component {
Div {
Link(url: url) {
Span().class("used-by-icon \(logo)").attribute(named: "title", value: name)
}.class("used-by-logo")
}.class("used-by-item")
}
}
40 changes: 40 additions & 0 deletions Sources/VaporDesign/Components/MainSite/FeatureContainer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Plot
import Publish

public struct FeatureContainer: Component {
let title: String
let description: String
let url: String
let icon: String?
let iconString: String?

public init(title: String, description: String, url: String, icon: String? = nil, iconString: String? = nil) {
self.title = title
self.description = description
self.url = url
self.icon = icon
self.iconString = iconString
}

public var body: Component {
Div {
Div {
if let icon = icon {
Span().class("vapor-icon \(icon)")
} else if let iconString = iconString {
Span(iconString)
}
H2(title)
Paragraph {
Text(description)
}
Button {
Link(url: "https://docs.vapor.codes/") {
Text("Get Started")
Span().class("vapor-icon icon-chevron-right")
}.linkTarget(.blank)
}.class("btn btn-primary w-mobile-100")
}.class("code-example-explainer")
}.class("col order-2 order-lg-1 g-lg-0")
}
}
30 changes: 30 additions & 0 deletions Sources/VaporDesign/Components/MainSite/PackageCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Plot
import Publish

public struct PackageCard: Component {
public let title: String
public let description: String
public let icon: String
public let url: String

public init(title: String, description: String, icon: String, url: String) {
self.title = title
self.description = description
self.icon = icon
self.url = url
}

public var body: Component {
Div {
Div {
Span().class("vapor-icon feature-card-icon icon-\(icon)")
H3(title).class("card-title")
Paragraph(description).class("card-text")
Link(url: url) {
Text("Learn More")
Span().class("vapor-icon icon-chevron-right")
}.linkTarget(.blank).class("learn-more-link")
}
}.class("card h-100 vapor-feature-card")
}
}
32 changes: 32 additions & 0 deletions Sources/VaporDesign/Components/MainSite/ShowcaseCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Plot
import Publish

public struct ShowcaseCard: Component {
let name: String
let url: String
let image: String
let description: String

public init(name: String, url: String, image: String, description: String) {
self.name = name
self.url = url
self.image = image
self.description = description
}

public var body: Component {
Div {
Image(url: image, description: "\(name) Card").class("card-img-top")
Div {
H5(name).class("card-title")
Paragraph(description).class("card-text")
Link(url: url) {
Text("See it in action")
Span("").class("vapor-icon icon-arrow-narrow-up-right")
}.class("btn btn-primary mt-auto")
}.class("card-body d-flex flex-column")
}.class("card")
.style("width: 18rem;")
.id("\(name.lowercased().replacingOccurrences(of: " ", with: "-"))-card")
}
}
30 changes: 30 additions & 0 deletions Sources/VaporDesign/Components/MainSite/SponsorCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Plot
import Publish

public struct SponsorCard: Component {
let name: String
let url: String
let logo: String
let description: String

public init(name: String, url: String, logo: String, description: String) {
self.name = name
self.url = url
self.logo = logo
self.description = description
}

public var body: Component {
Div {
Div {
Image(url: logo, description: name).class("card-img-top")
H5(name).class("card-title")
Paragraph(description).class("card-text")
Link(url: url) {
Text("Learn More")
Span().class("vapor-icon icon-chevron-right")
}.linkTarget(.blank).class("learn-more-link mt-auto")
}.class("card-body d-flex flex-column")
}.class("card")
}
}
36 changes: 19 additions & 17 deletions Sources/VaporDesign/Components/SiteFooter.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import Plot
import Foundation
import Plot

public struct SiteFooter: Component {

let isLocal: Bool
let isDemo: Bool
let currentSite: CurrentSite

public init(isLocal: Bool = false, isDemo: Bool = false, currentSite: CurrentSite) {
self.isLocal = isLocal
self.isDemo = isDemo
self.currentSite = currentSite
}

public var body: Component {
guard let year = Calendar(identifier: .gregorian).dateComponents([.year], from: Date()).year else {
fatalError("Unable to get the current year")
Expand All @@ -21,9 +20,7 @@ public struct SiteFooter: Component {
Div {
Div {
Div {
Span {

}.class("d-inline-block align-text-top")
Span().class("d-inline-block align-text-top")
.accessibilityLabel("Vapor Logo")
.id("vapor-logo-footer")
.width(197)
Expand All @@ -48,7 +45,7 @@ public struct SiteFooter: Component {
}
}
ListItem {
Link("Join our Discord", url: "https://vapor.team").linkTarget(.blank)
Link("Join our Discord", url: "https://vapor.team").linkTarget(.blank).class("nav-link")
}
ListItem {
if isDemo {
Expand Down Expand Up @@ -89,28 +86,28 @@ public struct SiteFooter: Component {
if currentSite == .blog {
Link("Blog", url: "/")
} else {
Link("Blog", url: "https://blog.vapor.codes").linkTarget(.blank)
Link("Blog", url: "https://blog.vapor.codes").linkTarget(.blank).class("nav-link")
}
}
ListItem {
if currentSite == .docs {
Link("Framework Docs", url: "/")
} else {
Link("Framework Docs", url: "https://docs.vapor.codes").linkTarget(.blank)
Link("Framework Docs", url: "https://docs.vapor.codes").linkTarget(.blank).class("nav-link")
}
}
ListItem {
if currentSite == .apiDocs {
Link("API Docs", url: "/")
Link("API Docs", url: "/").class("nav-link")
} else {
Link("API Docs", url: "https://api.vapor.codes").linkTarget(.blank)
Link("API Docs", url: "https://api.vapor.codes").linkTarget(.blank).class("nav-link")
}
}
ListItem {
Link("Press Kit", url: "https://design.vapor.codes/VaporPressKit.zip").attribute(named: "download", value: nil)
Link("Press Kit", url: "https://design.vapor.codes/VaporPressKit.zip").attribute(named: "download", value: nil).class("nav-link")
}
ListItem {
Link("Help", url: "https://vapor.team").linkTarget(.blank)
Link("Help", url: "https://vapor.team").linkTarget(.blank).class("nav-link")
}
}
}.id("footer-resources-links").class("col-6")
Expand All @@ -122,18 +119,23 @@ public struct SiteFooter: Component {
Div {
Text("&copy; QuTheory, LLC \(year)")
}.id("footer-copyright").class("my-auto")

Div {
List {
ListItem {
Link(url: "https://twitter.com/codevapor") {
Span().class("vapor-icon icon-twitter-fill")
}.linkTarget(.blank)
}.linkTarget(.blank).attribute(named: "rel", value: "me")
}.class("me-4")
ListItem {
Link(url: "https://hachyderm.io/@codevapor") {
Span().class("vapor-icon icon-mastodon-fill")
}.linkTarget(.blank).attribute(named: "rel", value: "me")
}.class("me-4")
ListItem {
Link(url: "https://github.com/vapor") {
Span().class("vapor-icon icon-github-fill")
}.linkTarget(.blank)
}.linkTarget(.blank).attribute(named: "rel", value: "me")
}
}.class("d-flex")
}.id("footer-social-links").class("ms-auto")
Expand Down
2 changes: 1 addition & 1 deletion Sources/VaporDesign/Components/SiteNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public struct SiteNavigation<Site: Website>: Component {
ListItem {
Link(url: "https://github.com/vapor") {
Span().class("vapor-icon icon-github-fill")
}.linkTarget(.blank).class("nav-link")
}.linkTarget(.blank).class("nav-link").attribute(named: "rel", value: "me")
}.class("nav-item")
ListItem {
Link(url: "#") {
Expand Down
16 changes: 9 additions & 7 deletions Sources/VaporDesign/VaporDesign.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,38 @@ import Plot
import Publish

public struct VaporDesign<Site: Website> {

let siteLanguage: Language
let isLocal: Bool
let isMainSite: Bool

public init(siteLanguage: Language, isLocal: Bool = false, isMainSite: Bool = false) {
self.siteLanguage = siteLanguage
self.isLocal = isLocal
self.isMainSite = isMainSite
}

public func buildHTML(for page: Location, context: PublishingContext<Site>, body: Node<HTML.DocumentContext>) -> HTML {
HTML(
.lang(siteLanguage),
buildHead(for: page, context: context),
body
)
}

func buildHead(for page: Location, context: PublishingContext<Site>) -> Node<HTML.DocumentContext> {
let head = Node.head(
for: page,
on: context.site,
stylesheetPaths: [
Path(VaporDesignUtilities.buildResourceLink(for: "/main.css", isLocal: isLocal))
Path(VaporDesignUtilities.buildResourceLink(for: "/main.css", isLocal: isLocal)),
],
scripts: [
Path(VaporDesignUtilities.buildResourceLink(for: "/js/detectColorScheme.js", isLocal: isLocal))
Path(VaporDesignUtilities.buildResourceLink(for: "/js/detectColorScheme.js", isLocal: isLocal)),
Path(VaporDesignUtilities.buildResourceLink(for: "/js/scrollMainSiteShowcase.js", isLocal: isLocal)),
Path(VaporDesignUtilities.buildResourceLink(for: "/js/mainSiteScrollNavbar.js", isLocal: isLocal)),
],
isLocal: isLocal)
isLocal: isLocal
)
return head
}
}
3 changes: 3 additions & 0 deletions src/images/allegro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/api-docs-background-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 76e0153

Please sign in to comment.