-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HTML implementation for
opacity
modifier (#415)
* Support `spacing` property on `HStack`/`VStack` * Remove unused properties in `StackDemo` * Implement stack spacing with grid gaps * Fix GTK build * Bump browser requirements in README.md * Remove outdated FIXME * Generalize snapshot timeouts * Prevent excessive CSS style leaks of properties * Add HTML implementation for `opacity` modifier * Update tests name to reflect file name * Fix missing semicolon in opacity style attribute Co-authored-by: ezraberch <49635435+ezraberch@users.noreply.github.com> * Remove duplicate declaration Co-authored-by: ezraberch <49635435+ezraberch@users.noreply.github.com>
- Loading branch information
1 parent
719c109
commit 738455b
Showing
8 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 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 1/20/21. | ||
// | ||
|
||
public struct _OpacityEffect: ViewModifier, Equatable { | ||
public let opacity: Double | ||
|
||
public init(opacity: Double) { | ||
self.opacity = opacity | ||
} | ||
|
||
public func body(content: Content) -> some View { | ||
content | ||
} | ||
} | ||
|
||
public extension View { | ||
func opacity(_ opacity: Double) -> some View { | ||
modifier(_OpacityEffect(opacity: opacity)) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Sources/TokamakStaticHTML/Modifiers/Effects/OpacityEffect.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2021 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 1/20/21. | ||
// | ||
|
||
import TokamakCore | ||
|
||
extension _OpacityEffect: DOMViewModifier { | ||
public var attributes: [HTMLAttribute: String] { | ||
["style": "opacity: \(opacity); "] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.52 KB
Tests/TokamakStaticHTMLTests/__Snapshots__/RenderingTests/testOpacity.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes