forked from allthesignals/labs-shared
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a square icon with a hatching pattern. Make the background color, hatch color, and hatch width adjustable closes #15
- Loading branch information
1 parent
8978e9c
commit 3719c71
Showing
5 changed files
with
55 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,9 @@ | ||
<svg width=".875em" height=".875em"> | ||
<defs> | ||
<pattern id="diagonalHatch" patternUnits="userSpaceOnUse" width="4" height="4" patternTransform="rotate(-45 2 2)"> | ||
<path d="M -1,2 l 6,0" stroke={{this.hatchColor}} stroke-width={{this.hatchWidth}} /> | ||
</pattern> | ||
</defs> | ||
<rect fill={{this.backgroundColor}} rx="2" ry="2" width="100%" height="100%" /> | ||
<rect fill="url(#diagonalHatch)" ry="2" rx="2" height="100%" width="100%" /> | ||
</svg> |
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,21 @@ | ||
import Component from '@glimmer/component'; | ||
import { htmlSafe } from '@ember/template'; | ||
|
||
export default class SquareHatchComponent extends Component { | ||
get backgroundColor() { | ||
const backgroundColor = this.args?.options?.backgroundColor; | ||
return backgroundColor !== undefined | ||
? htmlSafe(backgroundColor) | ||
: 'rgba(255, 255, 255, 1)'; | ||
} | ||
|
||
get hatchColor() { | ||
const hatchColor = this.args?.options?.hatchColor; | ||
return hatchColor !== undefined ? htmlSafe(hatchColor) : 'rgba(0, 0, 0, 1)'; | ||
} | ||
|
||
get hatchWidth() { | ||
const hatchWidth = this.args?.options?.hatchWidth; | ||
return hatchWidth !== undefined ? htmlSafe(hatchWidth) : '1'; | ||
} | ||
} |
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 @@ | ||
export { default } from '@nycplanning/ember/components/labs-ui/icons/square-hatch'; |
20 changes: 20 additions & 0 deletions
20
tests/integration/components/labs-ui/icons/square-hatch-test.js
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,20 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module( | ||
'Integration | Component | labs-ui/icons/square-hatch', | ||
function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{labs-ui/icons/square-hatch}}`); | ||
|
||
assert.strictEqual(this.element.textContent.trim(), ''); | ||
}); | ||
} | ||
); |