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

Edit In Place component #166

Merged
merged 25 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions src/components/Form/Controls/EditInPlace/EditInPlace.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
Copyright 2024 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.container {
min-block-size: 110px;
}

.label {
font-size: 15px;
font-weight: 500;
margin-block-end: 4px;
}

.controls {
display: grid;
grid-template-columns: 1fr auto;
gap: 15px;
}

.button-group {
display: none;
position: relative;
inset-block-start: 5px;
grid-template-columns: 1fr 1fr;
gap: 7px;
}

.button {
display: flex;
inline-size: 36px;
block-size: 36px;
border: 1px solid var(--cpd-color-border-interactive-secondary);
border-radius: 20px;
background-color: transparent;
text-align: center;
}

.primary-button {
background-color: var(--cpd-color-bg-action-primary-rest);
border-color: var(--cpd-color-bg-action-primary-rest);

svg {
color: var(--cpd-color-icon-on-solid-primary);
}
}

.primary-button-disabled {
background-color: var(--cpd-color-bg-subtle-primary);
border-color: var(--cpd-color-bg-subtle-primary);

svg {
color: var(--cpd-color-icon-disabled);
}
}

.button svg {
inline-size: 24px;
block-size: 24px;
margin: auto;
}

.control {
inline-size: 100%;
}

.container:focus-within .button-group {
display: inline-grid;
}

.container-error .control {
border-color: var(--cpd-color-border-critical-primary);
}

.container-error .label {
color: var(--cpd-color-text-critical-primary);
}

.caption-line {
margin-block-start: var(--cpd-space-2x);
}

.caption-icon {
display: inline-block;
vertical-align: middle;
inline-size: 20px;
block-size: 20px;
margin-inline-end: var(--cpd-space-2x);
}

.caption-icon-error {
color: var(--cpd-color-icon-critical-primary);
}

.caption-icon-saved {
background-color: var(--cpd-color-icon-success-primary);
border-radius: 20px;
text-align: center;
margin-inline-end: var(--cpd-space-2x);

svg {
color: var(--cpd-color-icon-on-solid-primary);
}
}

.caption-text {
vertical-align: middle;
font-size: 13px;
}

.caption-text-error {
color: var(--cpd-color-text-critical-primary);
}

.caption-text-saved {
color: var(--cpd-color-text-success-primary);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2024 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from "react";

import { EditInPlace } from "./";
import { Meta, StoryObj } from "@storybook/react";

type Props = { invalid?: boolean } & React.ComponentProps<typeof EditInPlace>;

export default {
title: "Form/Controls/EditInPlace",
component: EditInPlace,
tags: ["autodocs"],
parameters: {
controls: {
include: [
"onChange",
"onSave",
"onCancel",
"value",
"valueIsChanged",
"error",
"savedLabel",
"saveButtonLabel",
"cancelButtonLabel",
],
},
},
argTypes: {
label: {
type: "string",
},
value: {
type: "string",
},
valueIsChanged: {
type: "boolean",
},
onChange: {
action: "changed",
},
onSave: {
action: "saved",
},
onCancel: {
action: "cancelled",
},
error: {
type: "string",
},
savedLabel: {
type: "string",
},
saveButtonLabel: {
type: "string",
},
cancelButtonLabel: {
type: "string",
},
},
render: ({ ...restArgs }) => <EditInPlace {...restArgs} />,
args: {
label: "Label",
value: "",
saveButtonLabel: "Save",
cancelButtonLabel: "Cancel",
},
} satisfies Meta<Props>;

type Story = StoryObj<Props>;

export const Empty: Story = {
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?type=design&node-id=4335-2016&mode=design&t=BvxRca0YDRaq20IR-0",
},
},
};
Loading
Loading