-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2022 from cardstack/cs-7778-use-color-palette-for…
…-color-field-in-blog-category Use color palette for color fields in blog category
- Loading branch information
Showing
14 changed files
with
162 additions
and
35 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
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
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,40 @@ | ||
import { | ||
Component, | ||
FieldDef, | ||
StringField, | ||
contains, | ||
field, | ||
} from 'https://cardstack.com/base/card-api'; | ||
import { ColorPalette } from '@cardstack/boxel-ui/components'; | ||
import { ColorPicker } from '@cardstack/boxel-ui/components'; | ||
|
||
class View extends Component<typeof ColorPalette> { | ||
<template> | ||
<ColorPicker | ||
@color={{@model.hexValue}} | ||
@disabled={{true}} | ||
@showHexString={{true}} | ||
/> | ||
</template> | ||
} | ||
|
||
class EditView extends Component<typeof ColorPalette> { | ||
setColor = (color: string) => { | ||
this.args.model.hexValue = color; | ||
}; | ||
|
||
<template> | ||
<ColorPalette @color={{@model.hexValue}} @onChange={{this.setColor}} /> | ||
</template> | ||
} | ||
|
||
export class ColorField extends FieldDef { | ||
static displayName = 'Color'; | ||
@field hexValue = contains(StringField); | ||
|
||
static isolated = View; | ||
static embedded = View; | ||
static atom = View; | ||
static fitted = View; | ||
static edit = EditView; | ||
} |
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
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
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,39 @@ | ||
import { | ||
Component, | ||
FieldDef, | ||
StringField, | ||
contains, | ||
field, | ||
} from 'https://cardstack.com/base/card-api'; | ||
import { ColorPalette, ColorPicker } from '@cardstack/boxel-ui/components'; | ||
|
||
class View extends Component<typeof ColorPalette> { | ||
<template> | ||
<ColorPicker | ||
@color={{@model.hexValue}} | ||
@disabled={{true}} | ||
@showHexString={{true}} | ||
/> | ||
</template> | ||
} | ||
|
||
class EditView extends Component<typeof ColorPalette> { | ||
setColor = (color: string) => { | ||
this.args.model.hexValue = color; | ||
}; | ||
|
||
<template> | ||
<ColorPalette @color={{@model.hexValue}} @onChange={{this.setColor}} /> | ||
</template> | ||
} | ||
|
||
export class ColorField extends FieldDef { | ||
static displayName = 'Color'; | ||
@field hexValue = contains(StringField); | ||
|
||
static isolated = View; | ||
static embedded = View; | ||
static atom = View; | ||
static fitted = View; | ||
static edit = EditView; | ||
} |