From 3577469dec5dcedf559f3e3be4637e55b42185e3 Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Thu, 17 Sep 2020 14:35:56 -0400 Subject: [PATCH 1/7] Add Link View --- Package.swift | 17 +++++-- Sources/TokamakCore/Views/Buttons/Link.swift | 48 +++++++++++++++++++ Sources/TokamakStaticHTML/Core.swift | 3 ++ .../Modifiers/LayoutModifiers.swift | 2 +- .../Views/Buttons/Link.swift | 27 +++++++++++ 5 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 Sources/TokamakCore/Views/Buttons/Link.swift create mode 100644 Sources/TokamakStaticHTML/Views/Buttons/Link.swift diff --git a/Package.swift b/Package.swift index 2496a7aa5..8491bef39 100644 --- a/Package.swift +++ b/Package.swift @@ -4,6 +4,16 @@ import PackageDescription +#if os(WASI) +let otherDeps = [ + .package(url: "https://github.com/kateinoigakukun/JavaScriptKit.git", from: "0.5.0"), +] +let otherDepsInclude: [Target.Dependency] = ["JavaScriptKit"] +#else +let otherDeps = [Package.Dependency]() +let otherDepsInclude = [Target.Dependency]() +#endif + let package = Package( name: "Tokamak", platforms: [ @@ -37,10 +47,9 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(url: "https://github.com/kateinoigakukun/JavaScriptKit.git", from: "0.5.0"), .package(url: "https://github.com/MaxDesiatov/Runtime.git", from: "2.1.2"), .package(url: "https://github.com/MaxDesiatov/OpenCombine.git", from: "0.0.1"), - ], + ] + otherDeps, targets: [ // Targets are the basic building blocks of a package. A target can define // a module or a test suite. @@ -66,7 +75,7 @@ let package = Package( ), .target( name: "TokamakDOM", - dependencies: ["CombineShim", "JavaScriptKit", "TokamakCore", "TokamakStaticHTML"] + dependencies: ["CombineShim", "TokamakCore", "TokamakStaticHTML"] + otherDepsInclude ), .target( name: "TokamakShim", @@ -74,7 +83,7 @@ let package = Package( ), .target( name: "TokamakDemo", - dependencies: ["JavaScriptKit", "TokamakShim"] + dependencies: ["TokamakShim"] + otherDepsInclude ), .target( name: "TokamakStaticDemo", diff --git a/Sources/TokamakCore/Views/Buttons/Link.swift b/Sources/TokamakCore/Views/Buttons/Link.swift new file mode 100644 index 000000000..2983c62c6 --- /dev/null +++ b/Sources/TokamakCore/Views/Buttons/Link.swift @@ -0,0 +1,48 @@ +// Copyright 2018-2020 Tokamak contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Created by Carson Katri on 9/9/20. +// + +import struct Foundation.URL + +public struct Link