forked from primer/view_components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
105 additions
and
0 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,7 @@ | ||
--- | ||
'@openproject/primer-view-components': minor | ||
--- | ||
|
||
Add DragHandler component | ||
|
||
<!-- Changed components: Primer::OpenProject::DragHandler --> |
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,6 @@ | ||
<%= render Primer::BaseComponent.new(**@system_arguments) do %> | ||
<%= render(Primer::Beta::Octicon.new( | ||
icon: :grabber, | ||
size: @size | ||
)) %> | ||
<% end %> |
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,6 @@ | ||
/* CSS for DragHandler */ | ||
|
||
.DragHandler { | ||
cursor: move; | ||
color: var(--fgColor-muted); | ||
} |
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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module OpenProject | ||
# Add a general description of component here | ||
# Add additional usage considerations or best practices that may aid the user to use the component correctly. | ||
# @accessibility Add any accessibility considerations | ||
class DragHandler < Primer::Component | ||
status :open_project | ||
|
||
DEFAULT_SIZE = Primer::Beta::Octicon::SIZE_DEFAULT | ||
SIZE_OPTIONS = Primer::Beta::Octicon::SIZE_OPTIONS | ||
|
||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(size: Primer::OpenProject::DragHandler::DEFAULT_SIZE, **system_arguments) | ||
@system_arguments = system_arguments | ||
@system_arguments[:tag] = "div" | ||
@system_arguments[:classes] = | ||
class_names( | ||
@system_arguments[:classes], | ||
"DragHandler" | ||
) | ||
|
||
@size = fetch_or_fallback(Primer::OpenProject::DragHandler::SIZE_OPTIONS, size, Primer::OpenProject::DragHandler::DEFAULT_SIZE) | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
|
@@ -43,3 +43,4 @@ | |
|
||
/* OP specifics */ | ||
@import "./open_project/page_header.pcss"; | ||
@import "./open_project/drag_handler.pcss"; |
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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
# Setup Playground to use all available component props | ||
# Setup Features to use individual component props and combinations | ||
|
||
module Primer | ||
module OpenProject | ||
# @label DragHandler | ||
class DragHandlerPreview < ViewComponent::Preview | ||
# @label Default | ||
# @snapshot | ||
def default(size: :small) | ||
render(Primer::OpenProject::DragHandler.new(size: size)) | ||
end | ||
|
||
# @label Playground | ||
# @param size [Symbol] select [xsmall, small, medium] | ||
def playground(size: :small) | ||
render(Primer::OpenProject::DragHandler.new(size: size)) | ||
end | ||
end | ||
end | ||
end |
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
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
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require "components/test_helper" | ||
|
||
class PrimerOpenProjectDragHandlerTest < Minitest::Test | ||
include Primer::ComponentTestHelpers | ||
|
||
def test_renders | ||
render_inline(Primer::OpenProject::DragHandler.new) | ||
|
||
assert_selector(".DragHandler .octicon") | ||
end | ||
|
||
def test_renders_larger_icon | ||
render_inline(Primer::OpenProject::DragHandler.new(size: :medium)) | ||
|
||
assert_selector(".DragHandler .octicon[width='24']") | ||
end | ||
end |
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "system/test_case" | ||
|
||
class IntegrationOpenProjectDragHandlerTest < System::TestCase | ||
def test_renders_component | ||
visit_preview(:default) | ||
|
||
assert_selector(".DragHandler") | ||
end | ||
end |