Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add square hatch legend icon #16

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions addon/components/labs-ui/icons/square-hatch.hbs
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>
21 changes: 21 additions & 0 deletions addon/components/labs-ui/icons/square-hatch.js
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';
}
}
4 changes: 4 additions & 0 deletions addon/components/labs-ui/legend-icon.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<LabsUi::Icons::rectangle @options={{icon-layer}} />
{{/if}}

{{#if (eq @icon.type "square-hatch")}}
<LabsUi::Icons::square-hatch @options={{icon-layer}} />
{{/if}}

{{#if (eq @icon.type "fa-icon")}}
<LabsUi::Icons::fa-icon @options={{icon-layer}} />
{{/if}}
Expand Down
1 change: 1 addition & 0 deletions app/components/labs-ui/icons/square-hatch.js
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 tests/integration/components/labs-ui/icons/square-hatch-test.js
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(), '');
});
}
);
Loading