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
106 additions
and
1 deletion.
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 DragHandle component | ||
|
||
<!-- Changed components: Primer::OpenProject::DragHandle --> |
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 DragHandle */ | ||
|
||
.DragHandle { | ||
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 DragHandle < 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::DragHandle::DEFAULT_SIZE, **system_arguments) | ||
@system_arguments = system_arguments | ||
@system_arguments[:tag] = "div" | ||
@system_arguments[:classes] = | ||
class_names( | ||
@system_arguments[:classes], | ||
"DragHandle" | ||
) | ||
|
||
@size = fetch_or_fallback(Primer::OpenProject::DragHandle::SIZE_OPTIONS, size, Primer::OpenProject::DragHandle::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_handle.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 DragHandle | ||
class DragHandlePreview < ViewComponent::Preview | ||
# @label Default | ||
# @snapshot | ||
def default(size: :small) | ||
render(Primer::OpenProject::DragHandle.new(size: size)) | ||
end | ||
|
||
# @label Playground | ||
# @param size [Symbol] select [xsmall, small, medium] | ||
def playground(size: :small) | ||
render(Primer::OpenProject::DragHandle.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 PrimerOpenProjectDragHandleTest < Minitest::Test | ||
include Primer::ComponentTestHelpers | ||
|
||
def test_renders | ||
render_inline(Primer::OpenProject::DragHandle.new) | ||
|
||
assert_selector(".DragHandle .octicon") | ||
end | ||
|
||
def test_renders_larger_icon | ||
render_inline(Primer::OpenProject::DragHandle.new(size: :medium)) | ||
|
||
assert_selector(".DragHandle .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 IntegrationOpenProjectDragHandleTest < System::TestCase | ||
def test_renders_component | ||
visit_preview(:default) | ||
|
||
assert_selector(".DragHandle") | ||
end | ||
end |