Skip to content
Open
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
8 changes: 6 additions & 2 deletions src/Icons/IconSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ public function contents()
return $this->files()->map->getContents()->all();
}

public function get(string $name): string
public function get(string $name): ?string
{
return $this->filesystem->get($this->directory.'/'.$name.'.svg');
$path = $this->directory.'/'.$name.'.svg';

return $this->filesystem->exists($path)
? $this->filesystem->get($path)
: null;
}

private function files(): Collection
Expand Down
6 changes: 6 additions & 0 deletions tests/Fieldtypes/IconTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function it_accepts_svg_strings()
$this->assertStringContainsString('<svg class="w-4 h-4"', $result);
}

#[Test]
public function it_augments_a_missing_icon_to_null()
{
$this->assertNull($this->fieldtype()->augment('this-icon-does-not-exist'));
}

private function fieldtype($config = [])
{
return (new Icon)->setField(new Field('test', array_merge(['type' => 'icon'], $config)));
Expand Down
Loading